MySQL + SQL · Lesson 1
Login Authentication Query
Login Authentication
To log a user in, check if the email exists and the password matches — always using a prepared statement.
The Safe Query
-- use a prepared statement (? placeholder)
SELECT id, name, password
FROM users
WHERE email = ?;
Verify the Password in Code
Fetch the row by email, then verify the hashed password in your code (e.g. PHP password_verify). NEVER put the raw password directly in the SQL with string concatenation — that allows SQL injection.
Summary
- Query by email with a prepared statement, then verify the hashed password in code.
- Never concatenate user input into the query.