|
-
Jul 25th, 2007, 07:03 AM
#1
Thread Starter
Addicted Member
[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, $data, 1000);
fclose($fp);
}
$fr = fopen("data.dat","a+");
$newdata = "";
while ( feof($fr) == FALSE )
{
$newdata .= fread($fr, 1);
}
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>
-
Jul 25th, 2007, 02:35 PM
#2
Re: Disable HTML In Guestbook
My usual boring signature: Something
-
Jul 25th, 2007, 03:05 PM
#3
Thread Starter
Addicted Member
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, $data, 1000);
fclose($fp);
echo "Your message has been posted!";
}
?>
Is there anything wrong in that code?
-
Jul 25th, 2007, 04:59 PM
#4
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
-
Jul 25th, 2007, 05:48 PM
#5
Thread Starter
Addicted Member
Re: Disable HTML In Guestbook
Thanks
-
Jul 25th, 2007, 06:33 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|