Sign the guestbook
$self = $_SERVER['PHP_SELF'];
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$submit = $_POST['submit'];
$form = "";
if( !$submit){ $msg = $form; }
else
if( !$name or !$email or !$comments)
{
$msg = "Please complete all fields
";
$msg.= $form;
}
else
{
$conn = mysql_connect("localhost", "userName", "password") or die("Count not connect to database");
$rs = mysql_select_db("my_database",$conn) or die ("Could not select database");
if($name and $comments)
{
$sql = "insert into guestbook (name,email, comments)values (\"$name\",\"$email\",\"$comments\")";
$rs = mysql_query($sql,$conn)
or die ("Could not execute SQL query");
}
if($rs)
{
$msg = "Thank you - your entry has been saved.
";
$msg.= "";
$msg.= "View My Guestbook
";
}
}
echo($msg);
?>