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.
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

\n