// This script adds guestbook entries to the database.
// Address error handling. ini_set ('display_errors', 1);
if (isset ($_POST['submit'])) {if ($db_connect ('localhost', 'name', 'password'){
if (!@mysql_select_db ('name')) die (' Could not select the database because: ' . mysql_error() . ' '); }
} else { die (' Could not connect to MySQL because: ' . mysql_error() . ' '); }
// Define the query. $query = "INSERT INTO guest_entries (blog_id, name, email, aim, url, location, comments, date) VALUES (0, '{$_POST['name']}', '{$_POST['email']}', '{$_POST['aim']}', '{$_POST['url']}', '{$_POST['location']}', '{$_POST['comments']}', NOW())";
// Execute the query. if (@mysql_query ($query)) { print ' Thank you "$_POST('name')" for signing my guestbook. '; } else { print "ERROR
Could not submit guestbook entry because: " . $mysql_error . "." }
mysql_close();
?>
|