0

Dear friends,
I have an other problem in login form...my code is below..

//********************************connect to database and check****************************************************
$username = "root";
$password = "";
$database = "mydatabase";
$server = "127.0.0.1";

$conn= new mysqli($server,$username,$password,$database);
       // checkintin connection

       if($conn->connect_error){
                              die("connection failed:".$conn->connect_error);
        }   
   //****************fetch the information from database for match username and password *****************************
   $sql = "SELECT * FROM login1 WHERE L1='$username'";
   $result=$conn->query($sql);

                 if(!$result){
                              echo "invalid username"   ;       
                 } 
                 else{
                       echo "welcome";           
                 }

it is login.php form ..it connected database but does not reconize user name and password?

2
Contributors
2
Replies
28
Views
2 Years
Discussion Span
Last Post by zebnoon1
0

Try using result->num_rows instead (it returns number of rows found):

if($result->num_rows == 0){
    echo "invalid username" ;
} else {
    echo "welcome";
}

Edited by broj1

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.