This is a very simple way to clean all your $_POST or $_GET fields:
For AJAX requests: foreach ($_POST as $key => $value) $_POST[$key]=trim(strip_tags(urldecode($value)));
For standard forms: foreach ($_POST as $key => $value) $_POST[$key]=trim(strip_tags($value));
The script cycles through all your $_POST variables, converts them to their original format, strips out any possible code, and then gets rid of unnecessary spaces at the beginning or the end of the strings.
I figured someone here might find it useful. It's a very simple line of code but it gets the job done.
For AJAX requests: foreach ($_POST as $key => $value) $_POST[$key]=trim(strip_tags(urldecode($value)));
For standard forms: foreach ($_POST as $key => $value) $_POST[$key]=trim(strip_tags($value));
The script cycles through all your $_POST variables, converts them to their original format, strips out any possible code, and then gets rid of unnecessary spaces at the beginning or the end of the strings.
I figured someone here might find it useful. It's a very simple line of code but it gets the job done.