简体   繁体   中英

having issue in login form?

i am new in php and i am on learning phases, i created a register table in database and want to simple login by using register table data.

if(isset($_POST['submit'])){

    $name = $_POST['name'];
    $email = $_POST['email'];

    $login = "SELECT FROM register WHERE name='".$name."' AND email= '".$email."'  ";
    $run = mysqli_query( $con, $login );
    if ( mysqli_num_rows($run)>0 ) {
        echo "<script>alert('Logged In Successfully'); </script>";
    }

    exit();
}

Your query should be like Because you did not specify which data type you want to get from database

$login = "SELECT COUNT(*) FROM register WHERE name='".$name."' AND email= '".$email."'  ";

and then your code may change like

 if ( $run > 0 ) {
        echo "<script>alert('Logged In Successfully'); </script>";
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM