Hi
I'm just starting to learn PHP and have worked my way through the WebMOnkey tutorial on PHP and MYSQL. However, I'm having problems inserting checkboxes into my database. The values of my checkboxes and my field names in the DB are the same.
I'd really appreciate any help anyone could give me as I just have no clue as to how to solve this problem.
My code is as follows: (I'm using PHP3)
<body>
<?php
import_request_variables("rGP");
if ($submit) {
if (!$title || !$given_name || !$surname) {
$error = "Sorry! You didn't fill in all the fields!";
} else {
// process form
$db = mysql_connect("localhost", "username", "password");
mysql_select_db("form",$db);
$sql = "INSERT INTO test (title,given_name,surname,occupation,house_name,house_number,street,city,post_code,option_a,option_b,option_c)
VALUES ('$title','$given_name','$surname','$occupation','$house_name','$house_number','$street','$city','$post_code','$option_a','$option_b','$option_c')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
}
}
if (!$submit || $error) {
echo $error;
?>
<P>
<table width="100%" cellpadding="0" cellspacing="0" border="1">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
//HTML Form
etc...
<tr>
<th colspan="4" width"50%" align="left">
<input type="checkbox" name="option_a">
(a) [Drove too fast]
<br></br>
<input type="checkbox" name="option_b">
(b) [failed to keep a or any proper lookout]
<br></br>
<input type="checkbox" name="option_c">
(c) [failed to observe or heed in time adequately or at all the Claimant or the
Claimant's vehicle]
<br></br>
</th>
</tr>
</form>
</table>
<?php
} // end if
?>
</body>
Thanks
Rachael