check comment for html
Posted on
16th Feb 2014 07:03 pm by
admin
hi, I just wanted to check if a comment a user posts contains HTML, and if it does, to not allow it to be posted.
this is my current php, any help would be very much appreciated! thanks.
Did you know?Explore Trending and Topic pages for more stories like this.
Code:
<?php
$comment=$_POST['comment'];
$name=$_POST['name'];
$email=$_POST['email'];
$website=$_POST['website'];
$date=date("y/m/d h:i:s");
if($name && $email && $comment){
$sql="INSERT INTO `comments` (`name`, `email`, `website`, `articleid`, `comment`, `datetime`) VALUES ('$name', '$email', '$website', '$id', '$comment', '$date')";
$result=mysql_query($sql) or die(mysql_error());
if($result){
echo "Your comment was posted succesfully on the article n";
echo $rows['title'];
echo '<p><a href="view_article.php?id=';
echo $id;
echo '">Click here to go back to the article.</a></p>';
}else {
echo "Sorry, your comment could not be posted. Please make sure you fill in all the fields marked with *.n";
}
}else {
echo "Sorry, your comment could not be posted. Please make sure you fill in all the fields marked with *.n";
}
?>
No comments posted yet
Your Answer:
Login to answer
173
11
Other forums
Unable to customise toolbar in FCK
Undefined index: username HELP NEWBIE
I am trying a simple login/logout for my website. It works well with checking if the username exists
Best way to read this text file.
Hi.I am planning to make a small application in C# to convert the players from Football manager 2010
Add_Months not Easy to Understand
Oracle is number 1, very fast and very easy. But....
OK, I think but have a problem, only 1 pro
Working with popups and such in a class
I've recently started building my applications completely enclosed in classes. I like the fact that
need help with mail()
hi i want to send an email with attaching pdf file using php. i have the following script but the pr
Format timestamp from mysql
When I tried this:
Code: date("m/d/Y H:i A", $row['timestamp'])
I got 12/31/1969 18:
How to secure my login data to my database?
Hi there,
It may be a stupid question but I don't know how to secure my login data to my data
Members Only
Hi all, for my website i have a members area only which on members can veiw, but at the moment anyon
Sequre login with cookies.
I want to build secure login with cookies. I just want your ideas about this, your suggestions. What