Jump to content
Cooley

Trouble With Select PHP and MySQL

Recommended Posts

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);
                            
                        }

                    }

}

 

 

Share this post


Link to post
Share on other sites

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'] " ' ";

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...