this should not be hard but I'm struggling with it so I thought I'd request help as I could not finding anything specific on web.
I am posting from a checkbox on a form. When I look at the querystring in browser window when I freeze output, it shows, the names of the variables = on. Similarly, when I echo the posted values they show up as on. The problem is when inserting into the dbase although inputting TRUE works, on does not. Fieldtype is tinyint(1). Do I have to convert all the ons to TRUEs. I feel like this has never been a problem before.
<form action="processform.php" method="post">
<input type = "checkbox" name="var1" CHECKED>
<input type = "checkbox" name="var2" CHECKED>
<input type="submit" name="submit" value="submit"></form>
script on other end.
$var1 = $_POST['var1'];
$var2 = $_POST['var2'];
echo $var1; //echoes "on"
$sql = "INSERT into table (var1,var2) VALUES (TRUE,TRUE)"; //works
$sql = "INSERT into table (var1,var2) VALUES ($var1,$var2)"; //does not work.
$sql = "INSERT into table (var1,var2) VALUES ('$var1','$var2')"; //does not work.
mysql_query($sql);
Is this a typo? Can't imagine you really need to change "on" blank to TRUE or FALSE for each variable