YsoL8
YsoL8

Reputation: 2214

Problem proccessing checkbox on MAMP

I have two separately named checkboxes sending values to the following script. 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";
}

Upvotes: 0

Views: 57

Answers (1)

igorw
igorw

Reputation: 28249

Use isset():

$form = isset($_POST['form']) ? true : false;

Upvotes: 1

Related Questions