I’m not sure if this is the right way to do this, I have a contact form (processor code posted below) however I’m getting alot of html spam in the textarea. I’m trying to prevent this. I believe I would have to use strip_tags to do this?
When I googled my issue I found this bit of code:
should i be doing something with my $_REQUEST also as was suggested above…did i do something wrong in that regard (since i am only going to be applying the strip_tags to one field)?
$_REQUEST takes both $_POST and $_GET as possible inputs. This can cause ambiguity when you both post and get a key to those arrays. Ideally, you should be using either post or get, but almost never Request.
You should also be using strip_tags() on all pieces of input the user provides, not just the content field. I’m going to ask you to trust me on that one, because I truthfully don’t have time to explain things like cross site scripting at the moment.
$_REQUEST can also retrieve values from cookies so you don’t know when using that whether the value was passed using $_POST, $_GET or $_COOKIE
The only fields where you wouldn’t need to use strip_tags are those that are allowed to contain JavaScript and those where some other validation you are applying means that the field couldn’t possibly contain HTML (such as applying is_numeric or is_alphabetic instead).
In my first post in this thread I gave an example of how to change one of the fields. At no point was I trying to suggest that the change only needed to be made to that field. The same change needs to be made to all form fields (except where other validation is being applied instead of strip_tags).