I am new user, and I plan to design a form with 3 columns, and all the values will be stored in database. Each of columns can be null. However, there is an error message comes up if one of the column is not filled in.
Please help !!! Thank you so much
Error message--------------------------------
Notice: Undefined index: bread in c:\inetpub\wwwroot\phptest\qultest.php on line 8
Form--------------------------------------------------
<html>
<body>
<form action=qultest.php method=post>
Your name: <input type=text name=name size=30><br>
Your gender: <input type=radio name=gender value=0>female
<input type=radio name=gender value=1>male<br>
favorive foods:<br>
<input type=checkbox name=bread value=1>bread<br>
<input type=checkbox name=fruit value=2>fruit<br>
<input type=checkbox name=candy value=3>candy<br>
<input type=submit name=submit value=submit>
</form>
</body></html>
qultest.php--------------------------------------
<?php
if ((!$_POST['name'])){
header ("Location: http://sunfire100/phptest/qultest_form.php");
exit;
}
$name=$_POST['name'];
$gender=$_POST['gender'];
$bread=$_POST['bread'];
$fruit=$_POST['fruit'];
$candy=$_POST['candy'];
$connection=mysql_connect("localhost","root","") or die("couldn't connect.");
$db=mysql_select_db("phptestdb",$connection) or dir("couldn't connect to database");
$sql="insert into test1 values( \"$name\",\"$gender\",\"$bread\",\"$fruit\",\"candy\")";
$result=mysql_query($sql,$connection) or die ("couldn't query");
?>
Winter