I have this simple mysql query:
INSERT INTO table (col1, col2) VALUES ('1', '2')
col1
and col2
are foreign keys for another table so any value for col1
and col2
must be present in the other table or otherwise the row won't be inserted.
Is there still any risk of SQL injection in this case? If i receive these col values from PHP POST, do I still need to bind them before insertion into the database or they are already secure as the cols are foreign keys?
Yes. All input from users needs to be check for sanitized. E.g. if a user is sending you a string like that '2'); drop table <table>
as your second value it might get executed and giving you some surprise. (String might not work exactly, but I think you got the point)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With