[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>
Re: Disable HTML In Guestbook
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?
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);
Re: Disable HTML In Guestbook
Re: [RESOLVED] Disable HTML In Guestbook
no problem. thanks for the rep :)