Web Security · Middle · Question 63 of 75
How do you prevent SQL injection?
db.query("SELECT * FROM users WHERE email = '" + email + "'");- 1Remove single quotes from
emailwithreplace - ✓Correct answer: Use parameterized queries:
db.query('SELECT * FROM users WHERE email = $1', [email]) - 3Limit
emailto 50 characters
Explanation
With parameters, the database receives the query and the data separately, so input can never change the query's structure.