Comments on: How to login with username or email in PHP & MYSQL https://w3lessons.info/how-to-login-with-username-or-email-id-using-php-mysql Tutorials on PHP, jQuery & Amazon Web Services Wed, 22 Jul 2020 00:57:54 +0000 hourly 1 https://wordpress.org/?v=6.6.2 By: Sagar SN https://w3lessons.info/how-to-login-with-username-or-email-id-using-php-mysql#comment-752 Thu, 15 Oct 2015 08:37:00 +0000 http://w3lessons.info/?p=1749#comment-752 Thanks Karthikeyan and Dave that helped me a lot, i followed the same code for login using email/phone

]]>
By: Sumit https://w3lessons.info/how-to-login-with-username-or-email-id-using-php-mysql#comment-751 Tue, 01 Jul 2014 09:55:00 +0000 http://w3lessons.info/?p=1749#comment-751 Script is not working kindly provide the database

]]>
By: Karthikeyan K https://w3lessons.info/how-to-login-with-username-or-email-id-using-php-mysql#comment-750 Thu, 05 Dec 2013 05:42:00 +0000 http://w3lessons.info/?p=1749#comment-750 In reply to Dave.

Great Dave.. Here I just want to tell this to beginners.. anyway thanks for your nice suggestion 🙂

]]>
By: Dave https://w3lessons.info/how-to-login-with-username-or-email-id-using-php-mysql#comment-749 Wed, 04 Dec 2013 10:20:00 +0000 http://w3lessons.info/?p=1749#comment-749 Why so complicated? You don’t need to create a function to determine if the user is logging in with an email address or a username. Just let MySQL handle it – here is an example:

$name = $_POST[‘username’]; # userid can be an email address or a username
$pass = md5($_POST[‘password’]); # Password

$query = mysql_query(“SELECT * FROM `users` WHERE ‘$name’ IN (username, email) AND `password` = ‘$pass'”);

Also, your example is vulnerable to SQL injection… At that point, you should start using MySQLi or PDO + prepared statements. Don’t use this example in a production environment…

]]>