I have a form working and am using strip_tags and htmlentities to try and prevent any malicious code or spam links being submitted by the contact form. Is there a better way to write, that is to combine the following:
$comments = $_POST['comments'] ;
$comments = strip_tags($comments);
$comments = htmlentities($comments);
I would like to figure out how to write that in one statement if possible. Also, when I have it in the order above, only strip_tags or htmlentities only the one listed first (in the above strip_tags) works.
A final question, is htmlentities or stripslahses better for preventing spammy links being sent in a contact form?
Thank you!
1 Answer