Here are the errors im getting.
Notice: Undefined index: address in C:\wamp\www\Insertrecord.php on line 24
Notice: Undefined index: status in C:\wamp\www\Insertrecord.php on line 25
Notice: Undefined index: religion in C:\wamp\www\Insertrecord.php on line 26
Notice: Undefined index: region in C:\wamp\www\Insertrecord.php on line 27
Notice: Undefined index: zipcode in C:\wamp\www\Insertrecord.php on line 28
Notice: Undefined index: cpnumber in C:\wamp\www\Insertrecord.php on line 29
Insert Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Code, CP Number) VALUES ( '', '', '', '', '', '', '', '', '')' at line 1
Heres my code:
<html>
<head>
<title>Record Entry</title>
</head>
<body>
<center>
<br><br>
<br><br>
<br><br>
<br><br>
<b>
<?php
/* Variables Here */
$fname=$_POST['fname'];
$age=$_POST['age'];
$birthday=$_POST['birthday'];
$address=$_POST['address'];
$status=$_POST['status'];
$religion=$_POST['religion'];
$region=$_POST['region'];
$zipcode=$_POST['zipcode'];
$cpnumber=$_POST['cpnumber'];
/* Database Connection Start */
$con = mysql_connect('localhost', 'root' , '');
if (! $con)
{
die(mysql_error());
}
mysql_select_db("database" , $con) or die("Select Error: ".mysql_error());
$result=mysql_query("INSERT INTO Record (Name, Age, Birthday, Address, Status, Religion, Region, Zip Code, CP Number) VALUES (
'$fname',
'$age',
'$birthday',
'$address',
'$status',
'$religion',
'$region',
'$zipcode',
'$cpnumber')") or die("Insert Error: ".mysql_error());
mysql_close($con);
/* Database Connection Ends */
print "Record successfully added.";
?>
<br><br>
<form method="POST" action="Insertform.php">
<input type="submit" value="Insert Another Record">
</form>
<br><br>
<form method="POST" action="index.php">
<input type="submit" value="Back to Main Menu">
</form>
</center>
</body>
</html>
My Fields are right. I just don't get it, the first 3 $_POST are correct.