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?

Recommended Answers

All 2 Replies

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

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

Thank you very much Bro1
Problem is solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.