Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Kandy
Welcome all my all new pet shop Bark.lk
dilumrane
Updated:
Yesterday at 12:26 PM
Windows RDP Only Rs.500 a month
Blogerwiki
Updated:
Sunday at 12:41 PM
Ad icon
V2ray VPN for Tunneling
hu KANNA
Updated:
Oct 22, 2026
FREE SEO Check & Google Maps Check for Sri Lankan Businesses | Web Design, Website Price Rs 14,900 |
LankaSolve
Updated:
Oct 20, 2026
ඕනම රටකට සෙට් වෙන CV එකක්
ErMurazor
Updated:
Oct 17, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
Computers & Internet
Software Development
UseFul PHP Script`s n Code`s
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="MaD-DoC" data-source="post: 4130205" data-attributes="member: 56284"><p><strong>Simple guestbook</strong></p><p></p><p> <strong>Description</strong></p><p></p><p> Allows visitors to your site to read your guestbook entries and post a message of their own. Very simple setup, only requires you to change 4 settings. Uses MySQL to store the entries.</p><p> <strong>The code</strong></p><p></p><p> [PHP]<?php</p><p></p><p></p><p></p><p>/**</p><p></p><p> * Create the table in your MySQL database:</p><p></p><p> * </p><p></p><p> * CREATE TABLE guests (</p><p></p><p> * id int(10) NOT NULL auto_increment,</p><p></p><p> * name varchar(50) NOT NULL,</p><p></p><p> * message varchar(255) NOT NULL,</p><p></p><p> * date timestamp(14) NOT NULL,</p><p></p><p> * PRIMARY KEY (id)</p><p></p><p> * )</p><p></p><p> * </p><p></p><p> * Change the database login settings to your own</p><p></p><p> * </p><p></p><p> * The script is now ready to run</p><p></p><p> */</p><p></p><p></p><p></p><p>// Change these to your own database settings</p><p></p><p>$host = "localhost";</p><p></p><p>$user = "username";</p><p></p><p>$pass = "password";</p><p></p><p>$db = "database";</p><p></p><p></p><p></p><p>mysql_connect($host, $user, $pass) OR die ("Could not connect to the server.");</p><p></p><p>mysql_select_db($db) OR die("Could not connect to the database.");</p><p></p><p> </p><p></p><p>$name = stripslashes($_POST['txtName']);</p><p></p><p>$message = stripslashes($_POST['txtMessage']);</p><p></p><p></p><p></p><p>if (!isset($_POST['txtName'])) {</p><p></p><p></p><p></p><p> $query = "SELECT id, name, message, DATE_FORMAT(date, '%D %M, %Y @ %H:%i') as newdate FROM guests ORDER BY id DESC";</p><p></p><p> $result = mysql_query($query);</p><p></p><p> </p><p></p><p> while ($row = mysql_fetch_object($result)) {</p><p></p><p></p><p></p><p>?></p><p></p><p></p><p></p><p><p><strong><?php echo $row->message; ?></strong></p><p></p><p><br />Posted by <?php echo $row->name; ?> on <?php echo $row->newdate; ?></p></p><p></p><p></p><p></p><p><?php</p><p></p><p> </p><p></p><p> }</p><p></p><p> </p><p></p><p>?></p><p></p><p></p><p></p><p><p>Post a message</p></p><p></p><p></p><p></p><p><form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"></p><p></p><p></p><p></p><p> <p><label for="txtName">Name:</label><br /></p><p></p><p> <input type="text" title="Enter your name" name="txtName" /></p></p><p></p><p></p><p></p><p> <p><label for="txtMessage">Your message:</label><br /></p><p></p><p> <textarea title="Enter your message" name="txtMessage"></textarea></p></p><p></p><p> </p><p></p><p> <p><label title="Send your message"></p><p></p><p> <input type="submit" value="Send" /></label></p></p><p></p><p> </p><p></p><p></form></p><p></p><p></p><p></p><p><?php</p><p></p><p></p><p></p><p>}</p><p></p><p></p><p></p><p>else {</p><p></p><p></p><p></p><p> // Adds the new entry to the database</p><p></p><p> $query = "INSERT INTO guests SET message='$message', name='$name', date=NOW()";</p><p></p><p> $result = mysql_query($query);</p><p></p><p></p><p></p><p> // Takes us back to the entries</p><p></p><p> $ref = $_SERVER['HTTP_REFERER'];</p><p></p><p> header ("Location: $ref");</p><p></p><p>}</p><p></p><p></p><p></p><p>?> </p><p></p><p>[/PHP]</p></blockquote><p></p>
[QUOTE="MaD-DoC, post: 4130205, member: 56284"] [B]Simple guestbook[/B] [B]Description[/B] Allows visitors to your site to read your guestbook entries and post a message of their own. Very simple setup, only requires you to change 4 settings. Uses MySQL to store the entries. [B]The code[/B] [PHP]<?php /** * Create the table in your MySQL database: * * CREATE TABLE guests ( * id int(10) NOT NULL auto_increment, * name varchar(50) NOT NULL, * message varchar(255) NOT NULL, * date timestamp(14) NOT NULL, * PRIMARY KEY (id) * ) * * Change the database login settings to your own * * The script is now ready to run */ // Change these to your own database settings $host = "localhost"; $user = "username"; $pass = "password"; $db = "database"; mysql_connect($host, $user, $pass) OR die ("Could not connect to the server."); mysql_select_db($db) OR die("Could not connect to the database."); $name = stripslashes($_POST['txtName']); $message = stripslashes($_POST['txtMessage']); if (!isset($_POST['txtName'])) { $query = "SELECT id, name, message, DATE_FORMAT(date, '%D %M, %Y @ %H:%i') as newdate FROM guests ORDER BY id DESC"; $result = mysql_query($query); while ($row = mysql_fetch_object($result)) { ?> <p><strong><?php echo $row->message; ?></strong> <br />Posted by <?php echo $row->name; ?> on <?php echo $row->newdate; ?></p> <?php } ?> <p>Post a message</p> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> <p><label for="txtName">Name:</label><br /> <input type="text" title="Enter your name" name="txtName" /></p> <p><label for="txtMessage">Your message:</label><br /> <textarea title="Enter your message" name="txtMessage"></textarea></p> <p><label title="Send your message"> <input type="submit" value="Send" /></label></p> </form> <?php } else { // Adds the new entry to the database $query = "INSERT INTO guests SET message='$message', name='$name', date=NOW()"; $result = mysql_query($query); // Takes us back to the entries $ref = $_SERVER['HTTP_REFERER']; header ("Location: $ref"); } ?> [/PHP] [/QUOTE]
Insert quotes…
Verification
Asuwa dahayen wadi kalama keeyada?
Post reply
Top
Bottom