Cooley Posted June 13, 2020 Share Posted June 13, 2020 Hi, I have trouble with the following code, the login_success always returns false : Quote require_once('database_credentials.php'); $conn = new mysqli($db_servername,$db_username,$db_password,$db_name); $login_success = false; if(isset($_POST['email']) && isset($_POST['password'])){ if($conn->connect_error){ die ("Connection failed : ".$conn->connect_error); }else { $sql = "SELECT * FROM users WHERE email_address = ' ".$_POST['email']." ' AND password = '".$_POST['password']."' "; $result = $conn->query($sql); if($result){ $login_success = true; }else{ $login_success = false; echo 'error '.mysqli_error($conn); } } } Link to comment Share on other sites More sharing options...
dsonesuk Posted June 13, 2020 Share Posted June 13, 2020 You have space between single quotes and double quotes around email $_POST['email'] Link to comment Share on other sites More sharing options...
Sherin Posted June 30, 2020 Share Posted June 30, 2020 You can space between in single quote and double quote around the $_POST['password'] $sql = "SELECT * FROM users WHERE email_address = ' ".$_POST['email']." ' AND password =' " .$_POST['password'] " ' "; Link to comment Share on other sites More sharing options...
dsonesuk Posted June 30, 2020 Share Posted June 30, 2020 Well yea if all the emails are like ' imA@plagarist.com ' and passwords like ' butIstillGetItWrong ' NOTE: spaces before and after, + you missed period after password post. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now