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
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 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
Dawasata paya keeyak thibeda?
Post reply
Top
Bottom