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

error with opendir
when i do this

if ($handle = opendir($dir)) {
while (false !== ($file = readdir($han

Legal Issues for SAP ERP o ERP in general
Hi experts,

Can someone please help me finding some documentation about legal issues tha

what business processes?
Hi,

A general question. What business processes (like OTC - Order to Cach, P2P, R2R etc)

Floating Point Precision Loss
I'm writing a program to draw a three-dimensional cube (with a corner cut off) without using any 3D

IDOC error
Hi, When i send IDOC from ECC system to MII there is no problem ECC side, i says message sent succe

Working with Dates, help.
Sooo to make a long story short, here's what im trying to accomplish.

I need to create a drop

 formating when pulling data from a mysql database 
Ok so Im not to sure if this is the right thread to post in but here is my catch 22 issue.

I

Notice Undefined index: reset/ Attempting to redirect, works, but get a notice
Full Header.php is:
Code: [Select]<?php
$reset= false;
$reset= strip_tags($_GET[&quo

socket communication between c++/java and sending image
hi,

i have a class in c++ called win32_sockserver which creates socket to java. i am trying

Parse multirow HTML table
Hello all,
I have a site I am working on. Its a sports site and I am trying to add stats to a DB

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