Problem proccessing checkbox on MAMP
I have two separately named checkboxes sending values to the following sc开发者_StackOverflowript. I seem completely unable to reliably tell if the checkboxes are on or off.
I have checked the values are being sent in the $_POST and they are as expected. Please help!
$form = $_POST['form'];
$recruit = $_POST['recruiting'];
if (empty ($form)) {
$form = "0";
} else {
$form = "1";
}
if ($recruit) {
$recruit = "0";
} else {
$recruit = "1";
}
Use isset():
$form = isset($_POST['form']) ? true : false;
精彩评论