www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 24

Thread: Guestbook

  1. #1
    Join Date
    Apr 2003
    Location
    Nevada
    Posts
    411

    Guestbook

    I need a banner free guestbook with no links to other pages, just mine. So if anyone knows of a guestbook script let me know.. maybe i should ask PHP, but i need a guestbook... maybe a generator would be better.
    WARNING: non-exposure to the Son can cause burning!

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Here's a simple guestbook. It shouldn't be too hard to change the way it looks.... You can see it at http://www.infinitypages.com/temp/guestbook.php

    You will need a file named guestbook.txt CHMODed to 666 (read/writeable).

    PHP Code:
    <?PHP

    $filename 
    "guestbook.txt"#CHMOD to 666
    $text "";

    if (isset(
    $_POST["submit"])) {
        
    $name htmlspecialchars($_POST["name"]);
        
    $message htmlspecialchars($_POST["message"]);
        
        
    $date date ("l, F jS, Y");
        
    $time date ("h:i A");
        
        
    $value $message."<br>\n<span style=\"font-family: verdana, arial, sans-serif; font-size: 70%; font-weight: bold;\">Posted by $name at $time on $date.</span>\n<break>\n";

        
    ##Write the file##
        
        
    $fp fopen ($filename"a");
        if (
    $fp) {
            
    fwrite ($fp$value);
            
    fclose ($fp);
        }
        else {
            echo (
    "Your entry could not be added.");
        }
    }

    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
           "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Guestbook</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <form action="<?PHP echo $_SERVER["PHP_SELF"]; ?>" method="post">
    <p>Your Message:<br>
    <textarea name="message" rows="7" cols="50"></textarea><br>
    Your Name: <input type="text" name="name"> 
    <input type="submit" name="submit" value="submit"></p>
    </form>

    <?PHP

    $contents 
    = @file($filename) or die("No files in guestbook.");

    foreach (
    $contents as $line_num => $line) {
        
    $text .= $line;
    }

    $text split("<break>"$text);

    for (
    $i=0$i<count($text)-1$i++) {
        echo 
    "<div style=\"border: gray 1px solid; padding: 5px; font-family: arial, sans-serif; background-color: #eeeeee;\">";
        echo 
    $text[$i];
        echo 
    "</div>";
    }

    ?>
    </body>
    </html>

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  3. #3
    Join Date
    Apr 2003
    Location
    Nevada
    Posts
    411

    Wow, Thanks...

    What do I need to type in the Guestbook.txt and what is the CHMOD thing... not familiar...
    WARNING: non-exposure to the Son can cause burning!

  4. #4
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    You don't type anything in guestbook.txt... just upload the blank file. To CHMOD, you will need to FTP to your site, and check the documentation on how to CHMOD files...

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  5. #5
    Join Date
    Apr 2003
    Location
    Nevada
    Posts
    411
    So do I make the CHMOD blank and with notepad? Can you tall me how to create one
    ?
    WARNING: non-exposure to the Son can cause burning!

  6. #6
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    No, sorry. Let me explain what CHMOD is. CHMOD is the Unix/Linux way to change the permissions of a file. Basically, it is just a Unix command to tell the file to be able to be written to.

    Anyway, the script should create the file if it does not exist, so try just running guestbook.php without even uploading guestbook.txt... It should create it for you.

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  7. #7
    Join Date
    Apr 2003
    Location
    Nevada
    Posts
    411
    So I don't have to do anything, just copy&paste the php script into a "Guestbook.php"...
    Are you sure.. how will it keep track of the signatures?
    WARNING: non-exposure to the Son can cause burning!

  8. #8
    Join Date
    May 2003
    Posts
    550
    It will save them in guestbook.txt.
    Are you sure your server supports PHP?

  9. #9
    Join Date
    Apr 2003
    Posts
    853
    I am a bit confused as well.

    This code you gave Pyro, I copied it into notepad...so can I just upload that notepad file into my host directory then as well as the blank guestbook.txt file?

    Or do I need to paste the code you gave us onto a web page document then save it? I know this sounds painfully simple but I am unfamiliar with PHP.

    Secondly if I do have to paste the code into a web page document..do I have to save it as a PHP or just save it as I would any other web page?

    Thanks.
    Humankind cannot gain anything without first giving something in return.
    To obtain, something of equal value must be lost.
    That is Alchemy's first law of Equivalent Exchange.
    In those days we really believed that to be the worlds one, and only truth.
    - FullMetal Alchemist

  10. #10
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Basically what you do is take all the code in the PHP block above and copy it into any HTML/plain text editor. Then, save the file with a .php extention (for PHP to be processed, it must have a .php extention). So yes, just copy the code into notepad, and save with a .php extention. Now, make a .txt file named guestbook.txt and upload that to the server as well. Once it is on the server, CHMOD the guestbook.txt file to 666 (so the PHP script can write to it).

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  11. #11
    Join Date
    Apr 2003
    Posts
    853
    Oh..okay..that sounds easy enough. Thanks Pyro!
    Humankind cannot gain anything without first giving something in return.
    To obtain, something of equal value must be lost.
    That is Alchemy's first law of Equivalent Exchange.
    In those days we really believed that to be the worlds one, and only truth.
    - FullMetal Alchemist

  12. #12
    Join Date
    Apr 2003
    Posts
    853
    Okay..here is another inquery..I would like the newest entry to appear at the top..what do I need to alter in order to make this happen?

    Please keep in mind I am a complete idiot when it comes to PHP so don't get too techy on me.
    Humankind cannot gain anything without first giving something in return.
    To obtain, something of equal value must be lost.
    That is Alchemy's first law of Equivalent Exchange.
    In those days we really believed that to be the worlds one, and only truth.
    - FullMetal Alchemist

  13. #13
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Ok, try changing the ##Write the file## section to look like this (untested):

    PHP Code:
    ##Read old file##

    $contents = @file($filename);
    $file "";
    foreach (
    $contents as $line) {
        
    $file .= $line;
    }

    $post $file.$value;

    ##Write the file##

    $fp fopen ($filename"w");
    if (
    $fp) {
        
    flock($fpLOCK_EX);
        
    fwrite ($fp$post);
        
    flock($fpLOCK_UN);
        
    fclose ($fp);
    }
    else {
        echo (
    "Your entry could not be added.");


    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  14. #14
    Join Date
    Apr 2003
    Posts
    853
    Thanks Pyro..I am gonna try that then

    Here is what I have so far..tell me if this looks correct please.

    P.S..I altered the background color and text color..so that is why there is CSS.

    PHP Code:
    <?PHP

    $filename 
    "guestbook.txt"#CHMOD to 666
    $text "";

    if (isset(
    $_POST["submit"])) {
        
    $name $_POST["name"];
        
    $message $_POST["message"];
        
        
    $date date ("l, F jS, Y");
        
    $time date ("h:i A");
        
        
    $value $message."<br>\n<span style=\"font-family: verdana, arial, sans-serif; font-size: 70%; font-weight: bold;\">Posted by $name at $time on $date.</span>\n<break>\n";
    ##Read old file##

    $contents = @file($filename);
    $file "";
    foreach (
    $contents as $line) {
        
    $file .= $line;
    }

    $post $file.$value;

        
    ##Write the file##

    $fp fopen ($filename"w");
    if (
    $fp) {
        
    flock($fpLOCK_EX);
        
    fwrite ($fp$post);
        
    flock($fpLOCK_UN);
        
    fclose ($fp);
    }
    else {
        echo (
    "Your entry could not be added.");
    }

    }

    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
           "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Guestbook</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    body {background-color: rgb(24,24,24)}
    </style>
    </head>

    <body text="#FFFFFF">
    <form action="<?PHP echo $_SERVER["PHP_SELF"]; ?>" method="post">
    <p>Your Message:<br>
    <textarea name="message" rows="7" cols="50"></textarea><br>
    Your Name: <input type="text" name="name"> 
    <input type="submit" name="submit" value="submit"></p>
    </form>

    <?PHP

    $contents 
    = @file($filename) or die("No files in guestbook.");

    foreach (
    $contents as $line_num => $line) {
        
    $text .= $line;
    }

    $text split("<break>"$text);

    for (
    $i=0$i<count($text)-1$i++) {
        echo 
    "<div style=\"border: blue 1px solid; padding: 5px; font-family: arial, sans-serif; background-color: #000000;\">";
        echo 
    $text[$i];
        echo 
    "</div>";
    }

    ?>
    </body>
    </html>
    Last edited by Dark Dragon; 10-14-2003 at 04:25 PM.
    Humankind cannot gain anything without first giving something in return.
    To obtain, something of equal value must be lost.
    That is Alchemy's first law of Equivalent Exchange.
    In those days we really believed that to be the worlds one, and only truth.
    - FullMetal Alchemist

  15. #15
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Yeah, it looks good -- does it work for you?

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles