We have been working on a user registration system and it seems to be working rather well. The only thing is in initial testing we were able to get the common SQL injection string '1==1' into the database under one of the data fields. This is concerning from a development standpoint as it's one of the "forbidden strings" that should never get within 16 miles of a DB. The following code is what we are working with...
$query = $handler->query("INSERT INTO users (`username`,`password`,`first_name`,`last_name`,`email`,`IP_check`,`other_ip`,`rescue_email`,`proxy_flag`)
VALUES ('$UN','$password','$first','$last','$res_email','$IP_check','$other_IP','$res_email','$proxy_flag')");
where each of the strings is escaped with
$first = mysqli_real_escape_string($connect, $_POST['first_name']);
across all form values where $connect is a msqli instance defined in an include file, and the handler is a PDO database object initialized to work with the user database.
The data all gets to the table as we expect, but when we tried using the string '1==1' in one of the fields it passed to the database as is. Does this pose a valid SQL injection vector? On the sign in side it is more prominent to use the 1==1 and other vectors, but what we aren't sure of is whether or not getting a malicious string into the database poses an attack vector as well.