Web Security · Middle · Question 63 of 75

How do you prevent SQL injection?

db.query("SELECT * FROM users WHERE email = '" + email + "'");

Explanation

With parameters, the database receives the query and the data separately, so input can never change the query's structure.

Further reading

Problem with a question

Web Security · Middle · question 63

Test yourself

Take the Web Security · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz