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.


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 Like 11 Dislike
Previous forums Next forums
Other forums

Odd or Even
Inside of a while loop I need to echo several rows of info...easy enough.

In the loop (for th

mod_rewrite.c on windows ??
why it's not working on windows while it's working on other hosts???

this is the code i got

displaying unknown amount of results
I am reading a directory and getting a list of folders in the directory, I want to display the folde

PHP Surveys
I really would like some advice.

If you have a client come to you asking for a survey to be d

"GROUP BY" in arrays
Well i'm looking to do something i usually could do easily using COUNT and GROUP BY if it was a sql

Simple AND question
Hello,

I've got following code:

Code: if(strpos($row[13],"http://")

printing links
Hi every1

i am connecting to a table in sql and the looping through with a while ($ var = my

INSERT data problem!
After having an string with apostrophes ', double quotes " or any other special characters, suc

php or sql?
Sorry not sure if this is a sql problem or php the following code is supposed to delete data from th

Big O & time complexity ???
can you help me how to calculate the Big O & time complexity for any algorithm and c++ program pleas

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash