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

💻 Live Code Editor

Is page ki language (MYSQL) mein code likhein aur turant chalाएं — yahीं, bina kuch install kiye.
Powered by OneCompiler. Agar editor na khule to yahान naye tab mein kholein.

💻 Live Code Editor

Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें. Agar load na ho to naye tab mein kholें.