$dbHost = "localhost";
$dbUser = "hardcoder";
$dbPass = "hardcoder";
$dbDatabase = "hardcoder";
// Connect to DB
$li = mysql_connect($dbHost, $dbUser, $dbPass) or die("Could not connect");
mysql_select_db($dbDatabase, $li) or die ("could not select DB");
?>
// initiate some vars
$gb_str = ""; // $gb_str is the string we'll append entries to
$pgeTitle = "View and Sign Guestbook";
// If form is submitted, then insert into DB
if (!empty($HTTP_POST_VARS["submit"])) {
$name = $HTTP_POST_VARS["frmName"];
$email = $HTTP_POST_VARS["frmEmail"];
$comment = $HTTP_POST_VARS["frmComment"];
$date = Date("Y-m-d h:i:s");
$gb_query = "insert into guestbook
values(0, '$name', '$email', '$comment', '$date')";
mysql_query($gb_query);
$res = mysql_affected_rows();
// See if insert was successful or not
if($res > 0) {
$ret_str="Your guestbook entry was successfully added.";
} else {
$ret_str = "Your guestbook entry was NOT successfully added.";
}
// Append success/failure message
$gb_str .= "$ret_str
";
}
?>
// The querystring
$get_query = "select gbName, gbEmail, gbComment, DATE_FORMAT(gbDateAdded, '%m-%d-%y %H:%i') gbDateAdded
from guestbook";
$get_rs = mysql_query($get_query);
$gb_str .= "
< posted on $date $name>