Search

Saturday, October 15, 2011

How to Create a Guest Book With PHP

Websites are not familiar with the general public, but I need to question is whether people who access the Website we can recognize us? here are some tips to enhance your website and make our website a lot of people are familiar with the guest book. 

  

Well follow these steps: 

First create a database first, and was named the next "db_guestbook" and make table query guest_book , then enter the following query to create tables

    
CREATE TABLE `guest_book`
(
      `Id` int (5) NOT NULL auto_increment,
      `Name` varchar (30) NOT NULL COLLATE latin1_general_ci,
      `Email` varchar (50) NOT NULL COLLATE latin1_general_ci,
      `Website` varchar (200) NOT NULL COLLATE latin1_general_ci,
      `Message` text NOT NULL COLLATE latin1_general_ci,
      `Date` date NOT NULL,
      PRIMARY KEY (`id`)
        
) ENGINE = MyISAM DEFAULT CHARSET = latin1 COLLATE = latin1_general_ci AUTO_INCREMENT = 5;


The next stage now we create a file with a name "guest_book.php" contents with the following source:
  
    
<html>
    <head>
    <title>
        :: Guest Book V.1::
    </ Title>
    </ Head>
    <body>
        action="save.php" <form method="post">
            <table width="400" align="center">
            <tr>
                <td align="center" colspan="2" bgcolor="#9966FF"> <b> Simple Guest Book </ b> </ td>
            </ Tr>
            <tr>
                <td> Name </ td>
                <td> <input type="text" name="name" /> </ td>
            </ Tr>
            <tr>
                <td> Email </ td>
                <td> <input type="text" name="email" /> </ td>
            </ Tr>
            <tr>
                <td> Website </ td>
                <td> <input type="text" name="web" /> </ td>
            </ Tr>
                <td> Message </ td>
                <td> <textarea name="message" cols="30" rows="3"> </ textarea> </ td>
            </ Tr>
            <tr>
                <td align="center" colspan="2" bgcolor="#9966FF"> <input type="submit" value="Save Guest Books" /> </ td>
            </ Tr>
            </ Table>
        </ Form>
    </ Body>
    </ Html> 


Finally create a source to perform storage process to the database, save with the name "save.php":
   
    <? Php
    mysql_connect ("localhost", "root ","") or die (" Connection failed ");
    mysql_select_db ("db_guestbook") or die ("failed to connect database");
    $ Name = $ _POST ['name'];
    $ Email = $ _POST ['email'];
    $ Web = $ _POST ['website'];
    $ Message = $ _POST ['message'];
    $ Date = date ('Y-m-d');
    $ Query = mysql_query ("insert into values ​​guest_book ('','$ name ',' $ email ',' $ web ',' $ message ',' $ date')");
    if ($ query)
        {
            echo "Failed to save the guest book, please <a href=\"guest_book.php\"> repeat </ a>.";
        }
            else
        {
            echo "Thank you $ name has been filling the guest book.";
        }
    ?>

0 comments:

Post a Comment

 

Home | Blogging Tips And Trick | Simple Blogspot HTML | All About Informations | Interesting Site | Simple And Accurate Site

Copyright © 2010-2012 Interesting info Template Design by Fajar Hudy Pratama