mardi 15 décembre 2015

chaining if else statements

I have a form field in my website which i use for a table in my database. im using checkboxed for a true/false value. In my case my checkboxed send out an empty string if left unchecked.

I made an if else statement to make sure the empty string is made boolean. however, my if else statements only works for the first one ($ringe). the last two ($halskaeder and $armbaand) does not seem to work, as my database does not register any inputs.

I'm guessing my if else statement has flaws or syntax errors, im just too hopeless at PHP to figure out what's wrong.

if ($_REQUEST['ringe'] == ""){
$ringe = '0';
}
else {
$ringe = '1';
};


if ($_REQUEST['halskaeder'] == ""){
$halskaeder = '0';
}
else {
$halskaeder = '1';
};


if ($_REQUEST['armbaand'] == ""){
$armbaand = '0';
}
else {
$armbaand = '1';
};

Any help is highly appreciated!

Aucun commentaire:

Enregistrer un commentaire