My code
<?php
require('connect.php');
$name=$_POST['name'];
$comment=$_POST['comment'];
$submit=$_POST['submit'];
if($submit){
if($name&&$comment) {
$insert=mysql_query("INSERT INTO comment (name,comment) VALUES ('$name','$comment')");
}
else {
echo" please fill out the fields";
}
}
?>
<html>
<head>
<title>
The comment box
</title>
</head>
<body>
<form action="mainpage.php" method="POST">
<table>
<tr><td>Name:</td><td><input type="text" name="name"/></td></tr>
<tr><td colspan="2">Comment:</td></tr>
<tr><td colspan="2"><textarea name="comment"></textarea></td></tr>
<tr><td colspan="2"><input type="submit" name="submit" value="comment"/></td></tr>
</table>
</form>
</body>
</html>
It's very simple code, when I open the file I get these errors:
but they disappear after I add something in the textarea, but the inserted data doesn't go to database.
Notice: Undefined index: name in C:\xampp\htdocs\test\mainpage.php on line 5
Notice: Undefined index: comment in C:\xampp\htdocs\test\mainpage.php on line 6
Notice: Undefined index: submit in C:\xampp\htdocs\test\mainpage.php on line 7
Please help I tried everything.
connect.phpor just including the necessary classes/functions?