Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    need help with my Guestbook Script

    I've written a VERY simple guestbook script based on my request script. But i need some help with it.
    Now i've posted three times "Hello World!" you can view a demo here: http://www.roelt.nl/~sentinelmods/guestlog.php post a comment and see what the problem is. I want to make it separate comments by one line and Comment:
    here is the code i'm using to log comments to guestbook.php:
    PHP Code:
    Thank You for posting a comment! 
    <?php
    $file 
    "guestbook.php";
    $comment $_POST["comment"];

    if(
    is_writable($file)){
      
    $open fopen($file,"a");
      
    fwrite($open,$comment);
      
    fclose($open);
    }else{
      
    chmod($file,0777) or die("Note to myself: ".$file." to 0777!");
      echo 
    'W00ps! Something went wrong with the PHP script! Tell the staff!';
    }
    ?>
    <br>
    <?php include("guestbook.php"); ?>
    Here is the code i'm using for Guestbook.php:
    PHP Code:
    Comment: <?php echo $_POST["comment"]; ?>
    Please tell me how to separate comments.
    Cheers MPCODER
    Last edited by MPCODER; 01-23-2004 at 10:24 AM.

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The link is dead + i think we need to see the code where you display the comments (if i understand it correctly.

    I suppose you want to have a blank line between each comment? The easiest way looks like just adding 2 breaks at the end of the comment before writing it tothe file. Like replace

    $comment = $_POST["comment"];

    by

    $comment = $_POST["comment"] . '<br /><br />';

    A cleaner way would be to add them when after you read them from the file, or to put div-tags around each comment and then define the layout inside your CSS file.

  • #3
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    No,

    No, i wanted to separate comments by one line and Comment:
    So that if you post hello it says:
    Comment: Hello

    Comment: comment before it.

  • #4
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    $comment = "Comment: ". $_POST["comment"] ."<br /><br />";

  • #5
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks!

    Thanks Alot Taylor!

  • #6
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript

    EDIT: DON'T MIND THAT, I FOUND IT OUT MYSELF just a simple onclick="comment.value='<b>hoi</b>'">
    Last edited by MPCODER; 01-23-2004 at 08:33 PM.

  • #7
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Don't us clientside scripting if you can do it just as efficient with server side scripting.

    There is no point in first manipulating the commentvalue clientside (which wount work and which you have no control over) and then redo or further manipulate it serversided.

  • #8
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help

    Can you help me with a server-side solution? I have a problem with smillies. I want it to log <img src="images/amused.gif"> and it logs <img src=\"images/amused.gif\"> Is there a solution for this?

  • #9
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK, i've heard something about stripslashes ($tekst) but what do i do with that? Where do i put it? I want smillies to appear in guestbook.php

  • #10
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    $comment 'Comment: '$_POST['comment'] .'<br /><br />';
    //add this line below the line above
    $comment stripslashes($comment); 

  • #11
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It still doesn't work. Here i have my code for guestlog.php:
    PHP Code:
    <?php include("guestbook.php"); ?><form name="form1" id="form1" method="post" action="guestbooktry.php">
                Your Nickname: 
                <input name="name" type="text" id="name" />
                <br />
                Your Email: 
                <input name="email" type="text" id="email" />
                <br />
                Your Site: 
                <input name="site" type="text" id="site" value="http://" />
                <br />
                <input type="button" onclick="smillie.value='<b>text</b>'" value="Bold Text"><input type="button" onclick="smillie.value='<img src=&quot;images/amazed.gif&quot;>'" value=":-0" /><input type="button" onclick="smillie.value='<img src=/&quot;n//images/amuse.gif/&quot;n/>'" value=";-)"><input type="button" onclick="smillie.value='<img src=&quot;images/blink1.gif&quot;>'" value=";)"><input type="button" onclick="smillie.value='<img src=&quot;images/whip.gif&quot;>'" value=":whip:"><input type="button" onclick="smillie.value='<img src=&quot;images/mad.gif&quot;>'" value=":-(">
                Smillie code 
                <input name="smillie" type="text" id="smillie" value="smillies" />
                <br />
                Your Comment: 
                <textarea name="comment" id="comment"></textarea>
                <br />
                <input type="submit" name="Submit" value="Write Guesbook" />
              </form>
    Here is my code for guestbooktry.php, the file that logs the comments to guestbook.php.:
    PHP Code:
    <?php
    $file 
    "guestbook.php";
    $comment "Comment: "$_POST["comment"] ."<br /><br />";
    $name "Name: "$_POST["name"] ."<br />";
    $email "Email: "$_POST["email"] ."<br />";
    $site "Site: "$_POST["site"] ."<br />";
    $comment stripslashes($comment);


    if(
    is_writable($file)){
      
    $open fopen($file,"a");
      
    fwrite($open,$name);
      
    fwrite($open,$email);
      
    fwrite($open,$site);
      
    fwrite($open,$comment);
      
    fclose($open);
    }else{
      
    chmod($file,0777) or die("Attempted to chmod the file, it was unsuccessful, please chmod ".$file." to 0777 yourself");
      echo 
    'W00ps! Something went wrong with the PHP script! Tell the staff!';
    }
    ?><br /> <?php include("guestbook.php"); ?>
    And guestbook.php is an empty file. Can you please tell me what is wrong with this?

  • #12
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Someone please help me. A demo is up at http://www.roelt.nl/~sentinelmods/guestlog.php


  •  

    Posting Permissions

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