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

Writting a script to arrange images........ need some help
Ok so here is the link

http://hmtotc.com/dev/projects/vrassociates/jeweler_dev/admin/index.ph

retrieving policy name inside the function called by this particular policy
Hi there,

I've playing around with dbms_rls package, trying to set up some security repo

Credit card verification
I have a client who wants to process credit card transactions from his web site rather than the goin

urldecode question
How would I format this line of code properly?

<?php echo urldecode($_GET['Title']); ?

help connecting a form to php and then emailing the form
Ok. So, I made a form, and I need help to where when submitted, I get an email with the submitted de

user validation always displaying invalid ? please help
Hello,

I have 2 accounts and there is a field in mysql called validated it can be either &quo

Is there a way to override built in php functions without APD?
I am trying to use the
rename_function()
override_function()
options that are built into

Points for Wiki contribution
Hi everyone,

I want to know how long does it take for the moderator to award points for a

Simultaneous select/update/insert
Hi

How would I need to go about when 2 users update a single row simultaneous? And how would

How do I send data using an html link
Hi

If I have
<a href="main_file.php">

How do I send data t

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