PDA

View Full Version : best way to trim(stripslashes( each posted form item?


student101
07-12-2011, 09:42 PM
Instead of mulitple of these:

trim(stripslashes($_POST['item']));
trim(stripslashes($_POST['item1']));
trim(stripslashes($_POST['item2']));

I could use something like this:
function cleanposteditems(){
foreach ($_POST as $item => $val)
$_POST[$item] = trim(stripslashes($val));
}
BUT then I lose the $_POST['item'], $_POST['item1'] n so on :confused:

edbr
07-13-2011, 08:45 AM
use a function heres on i googled http://myphpform.com/validating-forms.php

student101
07-13-2011, 09:38 AM
Yeah thanks edbr :)