Answer the question
In order to leave comments, you need to log in
If you check the id for the presence of letters, can you protect yourself from sql injection?
That's what kind of check I have on the site
function check_for_number($str) {
$i = strlen($str);
while ($i--) {
if (is_numeric($str[$i]))
return true;
else {
echo '<script type="text/javascript">window.location.replace("example.com");</script>';
}
}
}
$idq = $_GET ['id'];
check_for_number ($idq);
Answer the question
In order to leave comments, you need to log in
First you must validate the http request.
And then use ORM or DBAL to execute the request, and use placeholders.
First, the redict is not very good . It's
better to do this: header ("Location: $url");
Secondly, if the string ends with a number, then it will return true.
If you need to calculate the ratio of digits to letters, then it is better to parse the digits with a regular expression and compare with the total number (after cutting off the spaces from the beginning and end).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question