Results 1 to 6 of 6

Thread: [RESOLVED] Disable HTML In Guestbook

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    190

    Resolved [RESOLVED] Disable HTML In Guestbook

    Is it possible to disable HTML in a guestbook? I'm using this script but people can put HTML code in, the code I'm using is:-

    PHP Code:
    <style>
    <!--
    p{ text-align: center }
    -->
    </style>

    <body>

    <?php

    if( empty($_POST['name'])==FALSE && empty($_POST['comments'])==FALSE )
    {
        
    $fp fopen("data.dat""a+");
        
    $data "<p><b>Name:</b> " $_POST['name'] . "<br>" "<b>Comments:</b>" $_POST['comments'] . "</p>";

        
    fwrite($fp$data1000);
        
    fclose($fp);
    }

    $fr fopen("data.dat","a+");
    $newdata "";
    while ( 
    feof($fr) == FALSE )
    {
        
    $newdata .= fread($fr1);
    }
    echo 
    $newdata;
    fclose($fr);
    ?>
    <p>----------------------------------------</p>
    <center><h2>Comment</h2></center>
    <form method="POST" action="guestbook.php">
    <p>
      Name<br>
      <input type="text" name="name" size="30"><br>
      Comments<br>
      <textarea rows="10" name="comments" cols="30"></textarea><br>
      <input type="submit" value="Submit" name="submit"><input type="reset" value="Reset" name="reset">
    </p>
    </form>

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Disable HTML In Guestbook

    My usual boring signature: Something

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    190

    Re: Disable HTML In Guestbook

    I've tried that but it doesn't strip the tags, heres the code I edited:-

    PHP Code:
    if( empty($_POST['name'])==FALSE && empty($_POST['comments'])==FALSE )
    {

    $comment=$_POST['comments'];

    $name=$_POST['name'];

    strip_tags($comment);
    strip_tags($name);

    //strip_tags($text, '<p><a>');

        
    $fp fopen("comments.dat""a+");
        
    $data "<p><b>Name:</b> " $name "<br>" "<b>Comments:</b>" $comment "</p>";

        
    fwrite($fp$data1000);

        
    fclose($fp);

        echo 
    "Your message has been posted!";
    }

    ?> 
    Is there anything wrong in that code?

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Disable HTML In Guestbook

    yah. here ya go:

    PHP Code:
    // change the strip tags lines to this:
    $comments strip_tags($comments);
    $name strip_tags($name); 
    My usual boring signature: Something

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    190

    Re: Disable HTML In Guestbook

    Thanks

  6. #6
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: [RESOLVED] Disable HTML In Guestbook

    no problem. thanks for the rep
    My usual boring signature: Something

Posting Permissions

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



Click Here to Expand Forum to Full Width