I have this code:
“SELECT * FROM colomn_name WHERE id = ‘$id’”
Can I know if it is SECURE way to get the id from database? P.S: I make FILTER_VAR that confirmed the id is numeric.
I have this code:
“SELECT * FROM colomn_name WHERE id = ‘$id’”
Can I know if it is SECURE way to get the id from database? P.S: I make FILTER_VAR that confirmed the id is numeric.
If you are worried about sql injection, then yes it is OK. But you need to be absolutely sure that id has only digits in it. Have a look here for many other tips.
A more secure way of doing this would be using prepared statements. The reason for this is that while input validation depends on the function used to make sure the input is correct, prepared statements would ensure that the statement and the values cannot be mixed leading to an sql injection. In the past there have been multiple problems with input validation libraries so it's not a completely secure solution. You can take a look here for more information.