Ik zit met een probleem, ik heb een newsscript gebouwd, en nu wil ik ervoor zorgen dat er geen html in de "comment" gepost kan worden. Nu heb ik uitgezocht hoe dit mogelijk is en dit heb ik gevonden:
$comment = nl2br(htmlentities($comment));
Nu is het probleem dat dit niet werkt, maar voor zover ik weet moet dit voldoende zijn...
Ik hoop dat iemand me hier mee kan helpen.
Bij voorbaat dank,
Sander
ps. hier is de code:
<?
if($add == "1"){
$add= "";
global $nid;
$timestamp=time();
//$comment_html = nl2br(htmlentities(comment));
$comment = nl2br(htmlentities($comment));
//$commenthtml = addslashes($commenthtml);
$sqlquery = "INSERT INTO sprnews_comments ( timestamp, cauthor, cemail, comment, newsid ) VALUES ( '$timestamp', '$c_author', '$c_email', '$comment', '$c_newsid');";
mysql_query($sqlquery);
$add= "";
}
$add= "";
global $nid;
?>
<br><hr size=1 color=black><br><b>Add Comment</b><br>
<form name="form1" method="post" action="<? $PHP_SELF ?>">
<input type="hidden" name="c_newsid" value="<? echo $nid ?>">
<table width="400" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="139">Name</td>
<td width="255">
<input type="text" name="c_author" value="">
</td>
</tr>
<tr>
<td width="139">Email</td>
<td width="255">
<input type="text" name="c_email" value="">
</td>
</tr>
<tr>
<td width="139">Comment</td>
<td width="255">
<textarea name="comment" cols="60" rows="5"></textarea>
</td>
</tr>
</table>
<div align="center"><br>
<input type="hidden" name="add" value="1">
<input type="submit" name="Submit" value="Post Comment">
<input type="reset" name="Submit2" value="Reset">
</div>
</form>
$comment = nl2br(htmlentities($comment));
Nu is het probleem dat dit niet werkt, maar voor zover ik weet moet dit voldoende zijn...
Ik hoop dat iemand me hier mee kan helpen.
Bij voorbaat dank,
Sander
ps. hier is de code:
<?
if($add == "1"){
$add= "";
global $nid;
$timestamp=time();
//$comment_html = nl2br(htmlentities(comment));
$comment = nl2br(htmlentities($comment));
//$commenthtml = addslashes($commenthtml);
$sqlquery = "INSERT INTO sprnews_comments ( timestamp, cauthor, cemail, comment, newsid ) VALUES ( '$timestamp', '$c_author', '$c_email', '$comment', '$c_newsid');";
mysql_query($sqlquery);
$add= "";
}
$add= "";
global $nid;
?>
<br><hr size=1 color=black><br><b>Add Comment</b><br>
<form name="form1" method="post" action="<? $PHP_SELF ?>">
<input type="hidden" name="c_newsid" value="<? echo $nid ?>">
<table width="400" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="139">Name</td>
<td width="255">
<input type="text" name="c_author" value="">
</td>
</tr>
<tr>
<td width="139">Email</td>
<td width="255">
<input type="text" name="c_email" value="">
</td>
</tr>
<tr>
<td width="139">Comment</td>
<td width="255">
<textarea name="comment" cols="60" rows="5"></textarea>
</td>
</tr>
</table>
<div align="center"><br>
<input type="hidden" name="add" value="1">
<input type="submit" name="Submit" value="Post Comment">
<input type="reset" name="Submit2" value="Reset">
</div>
</form>