Is it ok to use this code to trim and escape all post´s in my register function? or is it better practice to trim and escape each and every inputs
// Trim and sanitize our input
$_POST = array_map('trim', $_POST);
$_POST = array_map('mysql_real_escape_string', $_POST);
if (invalidinput) dostuff
else insert into user (username,passwd) values ('{$_POST['username']}','{$_POST['passwd']}')
No, because:
$_POST
value as a DB parameter and thus 3).mysql_real_escape_string()
might need the $link_identifier
argument.Point #1 can be worked out with a custom recursive function, at the expense of being even more slow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With