So I\'m new to php/the programming world and I\'m studying online and other forms and such but I couldn\'t find anything to help answer my question which is why I\'m here. Any h
Change related line to following: The problem is when activateBox is not empty it assings itself to $activeMain naturally.
$activeMain = isset($_POST['activateBox']);
Updated : Check this one.
function activeCheck() {
return isset($_POST['activateBox']);
}
activeCheck();
Updated Answer Due To Updated Question :
I removed session_destory
if you execute that and if you have another session variable ex: user isLoggedIn
it would be destroyed too. unset
is OK for the purpose. Please check XSS, Sql injection attacks around the internet implement logic according to best practises, and validate/sanitize your data before process parameters into DB or etc.
PHP FORM
$val) {
// sanitize your inputs. @see XSS, SQL injection etc.
// validate parameters according to your needs.
$safeParameters[$key] = $val;
}
$_POST = [];
checkIsActivated($safeParameters);
// implement other logic,
// save form to database etc.
}
function checkIsActivated($parameters)
{
return !empty($parameters['activateBox']);
}
?>