Hi,
im trying to create a form in php, when i click on the insert button it gives me a couple of errors!
here is the form code:
<html>
<head></head>
<title>contact form</title>
<body>
<h1>Insert New Record</h1>
<fieldset>
<legend>Personal Detail</legend>
<form action="insert.php" method="POST">
<p> First Name:<input type="text" name="fname" size="40" maxlength="30" />
</p>
<p> Last Name:<input type="text" name="lname" size="40" maxlength="30" />
</p>
<p> Email:<input type="text" name="email" size="40" maxlength="30" />
</p>
<p> Country:<input type="text" name="country" size="40" />
</p>
<p> Comment:<input type="text" name="comment" size="40" />
</p>
<input type="submit" value="Insert" />
<input type="reset" value="Erase" />
</fieldset>
</form>
</body>
</html>
and the php page:
<html>
<head></head>
<body>
<?php
$fname=$POST['fname'];
$lname=$POST['lname'];
$email=$POST['email'];
$country=$POST['country'];
$comment=$_POST['comment'];
$con= mysql_connect("localhost","root","");
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("groupproject",$con);
$sql="INSERT INTO contact (fname, lname, email, country, comment)
VALUES ('$fname','$lname','$email','$country','$comment')";
if(!mysql_query($sql,$con))
{
die('Error: ' .mysql_error());
}
echo "1 record added";
mysql_close($con);
?>
</body>
</html>
The error messages are:
Notice: Undefined index: name in D:\wamp\www\insert.php on line 7
Notice: Undefined index: rating in D:\wamp\www\insert.php on line 8
Can you guys tell me what is happening in line 7&8? thanks 🙂