I have a class that creates user accounts and to avoid SQL injection attacks, I am using the following functions to sanitize both the user name and password inputs:
$admUsername = filter_var($_POST['admUsername'], FILTER_SANITIZE_STRING);
$admPassword = filter_var($_POST['admPassword'], FILTER_SANITIZE_STRING);
$s->bindParam(':admUsername', $admUsername, PDO::PARAM_STR);
$s->bindParam(':admPassword', $admPassword, PDO::PARAM_STR);
But since I am using filter_var()
, when a user creates an account or tries to login, all the special characters like (?,/.!() that s/he inputs are removed. For that reason only alphanumeric characters can be used for the passwords, which might not always be good for the user's security. So my question is, if I use bindParam
, is it necessary to also use filter_var
or will bindParam
do the work that filter_var
does?
$s->bindParam(':admUsername', $_POST['admUsername'], PDO::PARAM_STR);
... I'm not saying don't usefilter_var
, just not for this. See : stackoverflow.com/questions/60174/… \$\endgroup\$