Sql query for login with email or username

This article is tagged with: Sql query for login with email or username and mysql

sql query for login with email or username

if($_POST['username'] != '' && $_POST['password'] != ''){$name = $_POST['username'];$pass = md5($_POST['password']);$check_email = Is_email($name);if($check_email){// email & password combination$query = mysql_query("SELECT * FROM `users` WHERE `email` = '$name' AND `password` = '$pass'");} else {// username & password combination$query = mysql_query("SELECT * FROM `users` WHERE `username` = '$name' AND `password` = '$pass'");}$rows = mysql_num_rows($query);if($rows > 0){//successfull login$_SESSION['username'] = $name;} else {$msg = "Invalid Login Credentials";}mysql_close($connection);} else {$msg = "Please Provide All Details";}

This article is tagged with: Sql query for login with email or username and mysql