I'm trying to make a script where people can post messages to me on my site, but somehow or another I need to block the < and > characters from being submitted. Idealy, I would make a script to find all instances of those characters and encode them. If thats not possible, is there some way to have the script give an error message if any of those characters are found in a submitted field? Thanks in advance
$string = htmlspecialchars($string);
This should remove all html characters from the post.
$message = str_replace('<', '', $message); $message = str_replace('>', '', $message);
That will remove < and > from the message. VooDooRT's code will convert special characters to HTML entities.