Register | Log in | RSS channel for codegravity.com homepage Bookmark!

284/2NEW projects | 71 services | 215 websites | 834/3NEW freelancers | 2126 topics | advertise



Login:



Forgot your password?
Forgot your username?
Create an account
JoomlaWatch Agent

Users

Most active users today from total of 109:
Peerke, garikello, jakkrit, dayanand, andrew_saber, giakhanh, mohalb, carmachhh, fguyon, dfireablaze, phoeker, ozedfr, boho, ashish_php, blackie, amoluca, JDev, tinytim007, Pascale, mayas_salman


19.9%United States United States
17.9%India India
9.3%Germany Germany
5.5%Russian Federation Russian Federation
4.4%United Kingdom United Kingdom
4.3%France France
4%Australia Australia
3.8%Netherlands Netherlands
3.8%Poland Poland
3.7%Italy Italy

Today: 976
Yesterday: 1402
This Week: 5266
Last Week: 8869
This Month: 2378
Last Month: 37593
Total: 117058


Partners:

HTML5, CSS3, SVG, tutorials

Freelance ColdFusion, Flex, PHP

Olejomalby, abstraktne obrazy

Camping Europe

WinAsm Studio

Vyšné Ružbachy

Sochy, Reštaurovanie

R.E.M.

Valid XHTML 1.0 Transitional

RSS feed:

Statistics:
Search Engine Genie Promotion Widget
Home

Simple guestbook in PHP and MySQL

Here is a code snippet of a simple guestbook in PHP and MySQL. It stores the data in the MySQL database and reads them with the PHP <?

/*
 * Example of simple guestbook in PHP & MySQL
 *
 * programmed by matto 2003, www.codegravity.com
 *
 */

$mysql_host = "www.codegravity.com";
$mysql_user = "matto";
$mysql_passwd = "";

$mysql_dbname = "codegravity";
$bodyname = "guest_book.php";
$db = @mysql_connect($mysql_host,$mysql_user,$mysql_passwd);
if (!$db) die("error!");

$result = @mysql_select_db($mysql_dbname,$db);
if (!$result) echo("error!");
mysql_query("create table guest_book (id int auto_increment primary key, name varchar(255), email varchar(255), message mediumtext) ",$db);
if (!isset($action))
{
    echo("
            <h3>Example of simple guestbook in PHP & MySQL</h3>
            <p>

            <form action='$bodyname' method=POST>
            name:<br>
            <input type=edit name=new_name>
            <p>

            email:<br>
            <input type=edit name=new_email>
            <p>
            message:<br>

            <textarea name=new_message></textarea>
            <p>
            <input type=hidden name=action value='record_insert'>

            <input type=submit value='submit record'>

            </form>
            <p>
            <font size=-1>Downloaded from <a href='http://www.codegravity.com'>www.codegravity.com</a> - internet database application development </font><hr>

            <p>
            ");
    $result = mysql_query("select * from guest_book",$db);
    while ($myrow = mysql_fetch_array($result))
    {
        echo("<b>name:</b> $myrow[1]<br> <b>email: </b>$myrow[2]<br> <b>message:</b> $myrow[3] <p>");

    }
    echo("
    ");
}

if ($action == "record_insert")
{
    $new_message = htmlspecialchars($new_message);
    $new_message = nl2br($new_message);
    $result = mysql_query("insert into guest_book values ('','$new_name','$new_email','$new_message') ",$db);

    if (!$result) echo("error!");
    header("location: $bodyname");
}
mysql_close($db);

?>  <p>
 
 

Comments  

 
-1 #1 ann 2007-09-05 18:42
It was very useful! Thanks!
Quote
 
 
-1 #2 Bbm 2008-03-16 02:09
Thanks!
It was very useful! Thanks!
Quote
 
 
+1 #3 Bill 2008-07-31 03:25
Thanks for article. Was useful.
Quote
 
 
0 #4 Ricky 2008-08-11 13:43
:-) thanks for article.it was fery useful
Quote
 
 
+1 #5 ava 2009-04-05 12:33
Thanks for article!
Quote
 
 
0 #6 madxerox 2009-05-15 11:29
very nice script !!! :-)
Quote
 
 
0 #7 Andrew Pall 2009-09-29 15:24
Nice guest book.
Quote
 
 
0 #8 Muppet 2009-10-28 02:48
it works on my site
Quote
 
 
0 #9 Netq 2009-11-20 02:39
Thanks!
It was very useful! Thanks!
Quote
 
 
0 #10 UniqueX 2010-06-12 08:21
thaks... ;-)
Quote
 
 
0 #11 stomatolog kraków 2010-08-09 14:29
Thanks for article!
Quote
 

Add comment


Security code
Refresh

No Tweets

Add URL of a programming website
register as a freelancer
submit your project
open freelance projects you can work on
webmaster resources
write paid blog posts about programming - tips and articles
bugs and features

Recommended: (advertise)
Download Joomlawatch 1.2.12


Register as a Freelancer -
Submit your project experiences, programming languages and your other skills


Freelancers, create paid articles
-
Looking for freelancers with experiences in Java to write paid articles on their experiences

Green Geeks Hosting -
World's best selling green web hosting


Advertise Here
-
Promote your services and get the new customers from the community of webmasters / programmers visiting CodeGravity.com


Outsource your project
-
Submit your project description with all the requirements to more than 600 freelancers from around the world for FREE.

HostMonster.com -
best cheap Joomla Web hosting. Website joomlawatchdemo.com is hosted by them with domain for $6,95/mo.

FastDomain.com -
Fast Domain hosting. Hostmonster alternative. Also for $6.95/month.



News from Twitter:
No Tweets
RSS Feeds:new

rss Freelance
rss Projects
rss Forum
rss Resources

Popular:
MathGuard
download mathguard
Random screenshot:

linoopz15.jpg


Poll

At what price would you purchase JoomlaWatch ad-free license?
 
Privacy policy | Advertise | Donate | Doucovanie Nemcina
Joomla Visitors Google Map
Loading map...
Joomla Visitors Google Map
Visitors Google Map Agent

Locations of visitors to this page


©2003-2010 Codegravity.com