Page 1 of 1

Sending 0 instead "" when radio button unchecked

Posted: Thu Dec 11, 2003 10:12 am
by Perfidus
I have a collection of radio buttons that have to send several values via post to database. When they are checked, they send the value but when they are unchecked, they send "" (nothing) and it is stored in table (In which default content was 0) this cause me troubles.
How can I send alternative value 0 when unchecked or how can I prevent this <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>?
:(

Posted: Thu Dec 11, 2003 10:54 am
by Perfidus
Mybe there's a way that detect and converts all "" empty values send by post in 0, so no empty values are stored in database! Any hints?

Posted: Thu Dec 11, 2003 10:56 am
by microthick
You could go:

if (!isset($_POST["myRadio"] || $_POST["myRadio"] == "") {
$myRadio = "0";
} else {
$myRadio = $_POST["myRadio"];
}

Posted: Thu Dec 11, 2003 11:43 am
by Perfidus
Thanks, it works!!
:lol: