I\'m trying to harden some of my PHP code and use mysqli prepared statements to better validate user input and prevent injection attacks.
I switched away from mysql
%
is not an inherently harmful character.
The question is: why are you using a LIKE
in the first place? Are there any circumstances in which you wouldn't require an exact match for username?
The query should be simply:
SELECT `salt` FROM admins WHERE `username` = ? LIMIT 1
In that case, if I were to enter %bsmith
my username would have to be (literally) "%bsmith" in order for you to find a match.