I have a file named blog.php
.
The Db name is blog
and the table name is comments
. (This is for a comment box)
connect.php
is my connection to the server. The action
is blog.php
.
My undefined variables are on lines: 3,4 & 5. I don't know why they are undefined, because in the tutorial there are no errors. Can you tell me why they are undefined?
<?php
require('connect.php');
$name = $_POST['name'];
$comment = $_POST['comment'];
$submit = $_POST['submit'];
if($submit){
if($name && $comment){
$insert = mysql_query("INSERT INTO blog(name,comment) VALUES('$name',' $comment')");
}else{
echo "Please fill out all the fields.";
}
}
?>
<!DOCTYPE html>
<html>
<head></head>
<body>
<form action="blog.php" method ="POST">
<table border="2" style="width: 250px; ">
<th> Post A Comment: </th>
<tr><td colspan="2">Name: <input type="text" name="name"></td></tr>
<tr><td >Comment: <textarea style="height: 100px; width: 200px;" name="comment"></textarea></td></tr>
</table>
<input type="submit" value="Comment" style="margin-left: 178px;" name="submit">
</form>
</body
</html>