If user input is inserted without modification into an SQL query, then the application becomes vulnerable to SQL injection, like in the following example:
That’s because the user can input something like value'); DROP TABLE table;--
, and the query becomes:
What can be done to prevent this from happening ?
Solution 1
You basically have two options to achieve this:
- Using PDO (for any supported database driver):