That's great! But do not do this in production đŸ˜¬ You should always sanitize the user input and never ever use a query param in your SQL, as that's injection 101.
What is not safe on the code? the $_GET['regex'] was bound thru $stmt->execute()
$_GET['regex']
There's no difference in safety between passing all the parameters as an array to execute, or using bindParam or bindValue.
bindParam
bindValue
Tried this simple injection and it doesn't work api.php?regex='or''='
api.php?regex='or''='
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That's great! But do not do this in production đŸ˜¬
You should always sanitize the user input and never ever use a query param in your SQL, as that's injection 101.
What is not safe on the code?
the
$_GET['regex']
was bound thru $stmt->execute()There's no difference in safety between passing all the parameters as an array to execute, or using
bindParam
orbindValue
.Tried this simple injection and it doesn't work
api.php?regex='or''='