This is a guestbook script, that stores all records in a MYSQL database. Displays records by pages. Highly configurable interface. For more information contact me at: nerd@kic.kmtn.ru See demo of the script at: http://php.inc.ru
By : lyonchik
<? /******************************************************************************** Guestbook by lyonchik: nerd@kic.kmtn.ru Contact me to report bugs, give your comments or to develop your own personalized Web applications.
This is a simple guestbook. It consists only of one file. All you need to do is create a MYSQL database table and set the variables below to conform to your settings and that's it. The sample query to create a table should be:
"CREATE TABLE guestbook (id int(5) NOT NULL auto_increment, name varchar(20), email varchar(20), message text, date datetime, PRIMARY KEY (id))"
And the guestbook is ready to go. Enjoy!
You can freely distribute this code. For any suggestions and comments write to: 'nerd@kic.kmtn.ru'. Feel free to email me URLs where this guestbook works, I would love to hear that my work is appreciated. *********************************************************************************/
// Define MYSQL server information $server = 'localhost'; // MYSQL server; $user = ''; // User to connect to MYSQL server; $password = ''; // Password; $database = 'database name'; // The name of the database; $table = 'guestbook'; // The name of your database table;
// Define page layout variables $guestbook_name = "My guestbook page"; // Guestbook page name; $titlecolor = 'black'; // Title font color; $tablewidth = "90%"; // Table width in pixels or percentage; $bgcolor = '#AAAAAA'; // Table background color value (name of hex equivalent); $bordercolor = '#000000'; // Table border color value (name of hex equivalent); $bordersize = 5; // Table border size; $cellspacing = 0; // Table cellspacing value; $cellpadding = 5; // Table cellpadding value; $messagecellcolor = '#BBAAAA'; // message cell color; $namecolor = '#0000EE'; // name font color; $messagecolor = '#000099'; // message font color; $mainfont = '#000033'; // main text font color; $maxshow = 10; // Number of messages to display per page; ?> <HTML> <META http-equiv=Content-Type content="text/html; charset=windows-1251"> <HEAD> <TITLE> <? echo $guestbook_name; ?> </TITLE> <script language="javascript"> function checkForm() { if ((document.forms.myGB.name.value == '') || (document.forms.myGB.message.value == '')) { alert('Fill in required fields!'); } else { document.forms.myGB.submit(); } } </script> </HEAD> <?
if (isset($message)) { if ($email == "") { $email = "no_email"; } mysql_connect ($server, $user, $password) or die ("Can't connect!"); mysql_select_db ($database) or die ("Can't open database!"); $sql = "INSERT INTO $table (name, email, message, date) VALUES ('$name', '$email', '$message', NOW())"; $result = mysql_db_query($database, $sql); if ($result) echo "<meta http-equiv='Refresh' content='0; URL=" . $PHP_SELF . "'>"; else echo "Error! Check the form!"; mysql_close(); }
if (!isset($show)) { $show = 0; } mysql_connect($server, $user, $password) or die ("Can't connect!"); mysql_select_db($database) or die ("Can't open database!"); $sql = "SELECT * FROM $table ORDER BY id DESC"; $result = mysql_db_query($database, $sql); if ($result) { $count = mysql_num_rows($result);
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.