Thread: PHP Guestbook

Results 1 to 4 of 4
  1. #1
    Zebra's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    5
    My Mood
    Brooding

    PHP Guestbook

    Hey guys, here's the Guestbook i made.

    Ok so lets start.
    First make a new database named "guestbook", And execute this SQL Script:
    Code:
    CREATE TABLE messages(
    id INT NOT NULL AUTO_INCREMENT,
    PRIMARY KEY(id),
    nick VARCHAR(20) NOT NULL,
    message TEXT NOT NULL,
    ip TEXT NOT NULL,
    time TEXT NOT NULL
    );
    Now make three new PHP files.

    1.index.php:
    [html]
    <!-- This Guestbook has been made By Zebra -->
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    <head>
    <title>Guestbook</title>
    <style type="text/css">
    body{
    font-size:11pt;
    font-family:Verdana;
    }
    </style>
    <?php include "functions.php"; ?>
    </head>

    <body>
    <table width="450" style="border:1px solid black;border-collapse:collapse;" align="center">
    <th>Guestbook<hr /></th>
    <?php ShowMsgs(); ?>
    <tr>
    <form action="" method="POST" style="text-align:center;">
    <td>
    <?php @Post($_POST['nick'],$_POST['msg'],$_POST['submit']); ?>
    Nickname:<input type="text" name="nick" size="33" /><Br />
    Message:<br />
    <textarea name="msg" cols="35" rows="8" tabindex="100" ></textarea>
    <br />
    <input type="submit" name="submit" value="Post" />
    </td>
    </form>
    </tr>
    </table>
    </body>

    </html>
    [/html]

    2.config.php(Remember to edit the host,user,password):
    [php]
    <?php
    $host = "localhost"; //Put here your mysql host
    $user = "root"; //Put here you mysql user
    $pass = "root"; //Put here you mysql pass
    $db = "guestbook"; //Put here the DB your using

    $conn = mysql_connect($host,$user,$pass) or die(mysql_error());
    $sdb = mysql_select_db($db) or die(mysql_error());
    ?>
    [/php]

    3.functions.php:
    [php]
    <?php
    include "config.php";
    function ShowMsgs(){
    $sq = mysql_query("SELECT * FROM `messages` ORDER BY `id` DESC");
    while($row = mysql_fetch_array($sq)){
    echo "
    <tr>
    <td>
    " . $row['time'] . " - " . $row['nick'] . ":<br />" . nl2br(htmlentities($row['message'])) . "<br /><hr />
    </td>
    </tr>
    ";
    }
    }
    function Post($nick,$msg,$sub){
    if(isset($sub)){
    $nick = mysql_real_escape_string($nick);
    $msg = mysql_real_escape_string($msg);
    $ip = $_SERVER['REMOTE_ADDR'];
    $h = date("g") - 1;
    $time = date($h . ":i A:j/n/Y");
    if($nick == ""){
    echo "<font color='red'>You must provide a Nickname.</font><br />";
    }elseif(strlen($nick) > 20){
    echo "<font color='red'>Your nick must be between 1 And 20 Charecters.</font><br />";
    }elseif(strlen($msg) < 6){
    echo "<font color='red'>Your Message is to short.</font><br />";
    }elseif($msg == ""){
    echo "<font color='red'>You must provide a Message.</font><br />";
    }else{
    $insert = mysql_query("INSERT INTO `messages` (`nick`,`message`,`ip`,`time`) VALUES ('" . $nick . "','" . $msg . "','" . $ip . "','" . $time . "') ");
    if($insert == true){
    Header("Location:index.php");
    }else{
    echo "<font color='red'>There was a problem posting your comment.</font><br />";
    }
    }
    }
    }
    ?>
    [/php]

    Ok, now you have your own Guestbook ^^.

    Download files:https://mesolottery.com/other/Guestbook.zip

    -Zebra
    Last edited by Zebra; 10-07-2009 at 12:18 PM.

  2. The Following User Says Thank You to Zebra For This Useful Post:

    Shaklobot (10-08-2009)

  3. #2
    Ugleh's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    House, Where you live?
    Posts
    276
    Reputation
    17
    Thanks
    221
    My Mood
    Blah
    some users might not know how to set up a database, ill make a thread later but nice work.

  4. The Following User Says Thank You to Ugleh For This Useful Post:

    imamage597 (02-05-2013)

  5. #3
    Zebra's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    5
    My Mood
    Brooding
    How they can not know it?
    Its simple...

  6. #4
    Troy598's Avatar
    Join Date
    Apr 2013
    Gender
    female
    Posts
    8
    Reputation
    10
    Thanks
    0
    Yeah, I have the same problems of the people above me.[img]https://***********/12.jpg[/img]
    Last edited by Troy598; 04-02-2013 at 08:01 PM.

Similar Threads

  1. Replies: 4
    Last Post: 02-18-2014, 06:40 PM
  2. [PHP]Based DoS Blocker
    By Token in forum General Hacking
    Replies: 0
    Last Post: 10-13-2008, 10:00 PM
  3. Selling Phising files [Php & Mysql]
    By niek123 in forum Trade Accounts/Keys/Items
    Replies: 7
    Last Post: 03-27-2008, 11:27 AM
  4. PhP Programming Section
    By radnomguywfq3 in forum Suggestions, Requests & General Help
    Replies: 8
    Last Post: 01-30-2008, 08:13 PM
  5. Process_promocode.php[code]
    By ferrar1000 in forum WarRock - International Hacks
    Replies: 22
    Last Post: 10-02-2007, 06:55 PM

Tags for this Thread