Use this page to say what you think of this web site The form is at the bottom of the page.
// Copyright (C) 2000 Sylvain BAUDOIN // // The PHP3 code of this page may be redistributed and/or modified according to the terms of the GNU // General Public License, as it has been published by the Free Software Foundation (version 2 and // above) // // We retrieve the number of the page to be displaid as well as all other possible form parameters parse_str(getenv("QUERY_STRING")); if (($page == "") || ($page < 0)) { // Page numbering starts from 0 $page = 0; } $nameform = $name; $mailform = $mail; $messageform = $message; // We prepare the connection to the MyQSL server $host = "mysql_server"; $user = "database_user"; $password = "password"; // Connection mysql_connect($host, $user, $password) or die ("cannot connect to the MySQL server"); mysql_select_db($bdd) or die ("cannot connect to the database"); // We first treat the possible message to add // Is there a message to add? if ($message != "") { $message = htmlentities($message); // Is there a name? if ($name != "") { // We calculate the date $date = date("YmdHis", time()); // Query to add the new message $query = "INSERT INTO guest_book (Date, Name, Mail, Message) VALUES ($date, \"$name\", \"$mail\", \"$message\")"; mysql_query($query) or die ("cannot insert the message"); $nameform = ""; $mailform = ""; $messageform = ""; } else { echo "you must give your name
\n"; } // If there is no message, we check if a name has been provided } else { if ($name != "") { echo "You must write a message
\n"; } if (($mail != "") && ($name == "")) { echo "You must give your name
\n"; } } // Now, we retrieve the messages to display $query = "SELECT * FROM guest_book ORDER BY Date DESC"; $result = mysql_query($query); // Number of messages $nbr = mysql_num_rows($result); // If we ask for a page that does not exists yet, we return the last page if ($page*10+10 > $nbr) { $page = ($nbr-$nbr%10)/10; } // We look for messages to display according to the page for($i = $page*10; ($i < $nbr) && ($i < $page*10+10); $i++) { if (! mysql_data_seek($result, $i)) { continue; } if (! $row = mysql_fetch_row($result)) { continue; } // We display messages list($years, $month, $day) = split("-", substr($row[0], 0, 10)); $name = $row[1]; $mail = $row[2]; $message = $row[3]; echo "| $name "; if ($mail != "") { echo "($mail) "; } echo "- $day/$month/$year |
| $message |
| Give a message |