I created a Guestbook. But people can submit comments without writing any thing in the field. I mean they can submit null (empty) comments. Can anyone help me to fix this?? I tried to fix this.. but I couldn't
Here is the source code of form action file (addguestbook.php)
Code:
<?php
include("config.php");
$tbl_name="xxx"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$dbname")or die("cannot select DB");
$datetime=date("y-m-d h:i:s"); //date time
$name = htmlentities($name);
$email = htmlentities($email);
$comment = htmlentities($comment);
$sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')";
$result=mysql_query($sql);
//check if query successful
if($result){
header ("Location:comments.php");
}
else {
echo "ERROR";
}
mysql_close();
?>
check for the comments field being empty and if it is ...
... don't add it to the database
__________________
Chris. ->> Please login or register to view this content. Registration is FREE <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
<?php include("config.php"); $tbl_name="xxx"; // Table name
// Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$dbname")or die("cannot select DB");
<?php include("config.php"); $tbl_name="xxx"; // Table name
// Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$dbname")or die("cannot select DB");