Please take a moment to share your comments with us. If you have a specific question for us, please use the form located here.
Thanks! We appreciate your comments on our program.
else:
// lastly, we must be at the main page. Get the number of entries in the guestbook
//so we can tell the visitor how many there are
$result = mysql_query( "select max(id) from guestbook");
$row = mysql_fetch_row($result);
$num = $row[0];
if ($num == "") {
$entry = "There are currently no entries";
}
elseif ($num == "1") {
$entry = "There is currently 1 entry";
}
else {
$entry = "There are currently $num entries";
}
echo " Welcome to the Calculus&Mathematica guestbook. $entry in the guestbook.";
echo "
Your E-mail address:
Your Web Page address:
Your occupation:
Where you call home:
Comments:
View Guestbook Entries
";
// get stuff from the database
$result = mysql_query( "select name, email, url, job, location, comments from guestbook");
// fetch the rows one at atime, and then echo the data to the page
while ($row = mysql_fetch_row($result)) {
echo "
";
echo "Name: $row[0]";
echo "
E-mail: $row[1]";
echo "
Web Page: $row[2]";
echo "
Occupation: $row[3]";
echo "
From: $row[4]";
echo "
Comments:";
echo "
$row[5]";
}
// if we're submitting a guestbook entry
elseif (isset($cmd) && $cmd == "send"):
// open a pipe to the mail server, andsend a copy to the admins,
// the mail() function could also have been used
$fd = popen ($MP, "w");
fputs ($fd, "To: $mail\n");
fputs ($fd, "Subject: Guestbook Addition\n");
fputs ($fd, "$name ($email) has added the following to the guestbook\n");
fputs ($fd, "Web Page: $url\n");
fputs ($fd, "Occupation: $job\n");
fputs ($fd, "Location: $location\n");
fputs ($fd, "$comments\n");
pclose ($fd);
// MySQL really hates it when you try to put things with ' or "
// characters into a database
$comments = addslashes( "$comments");
mysql_query( "insert into guestbook (name, email, url, job, location, comments) values
// insert the data into the database
('$name', '$email', '$url', '$job', '$location', '$comments')");
?>
Add an entry to the guestbook
";
echo "View entries in the guestbook
";
endif;
?>