简体   繁体   中英

SERVER shows BLANK WHITE PAGE after submitting CORRECT login details

I have written a login script using mysqli and the complete script works up till the part where I've actually entered correct details. If I leave the fields blank or input incorrect details it displays a message to the user .. which is great! But say I enter the correct username and password combination.. it doesn't direct to the page I've asked it to.. it just shows me a white screen... see code below:

<?php
    // Create a connection
    include("dbconfig.php");    

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

        if( empty( $_POST['username'] ) or empty( $_POST['password'] ) ){

            header("location:index.php?msg0=Please complete the required fields.");

        } elseif ( !empty( $_POST['username'] ) && !empty( $_POST['password'] ) ){

            $username = $_POST['username'];
            $password = $_POST['password'];

            $sql = mysqli_query($conn, "SELECT username, password FROM logininformation WHERE username = '$username' and password = '$password'") or die (mysqli_error($conn));
            $login = ($sql) ? mysqli_fetch_assoc($sql) : false;

            if( $login == 0 ){
                header("location: index.php?msg1=Invalid username or password, please try again.");
            } elseif( $login == 1 ){
                header("location: userlogin.php?uid=$username");
            }
       }    
    }
?>

Please could someone advise me on what I'm doing wrong. Help will be much appreciated.

Thanks,

Sohail.

在代码的最后elseif条件下,尝试删除== 1的检查,然后运行代码...如果仍然无法正常工作,请尝试将错误日志文件粘贴到此处。

I know it's crazy, answering my own question... but I found the solution. See below:

Before:

elseif(($login) == 1){

header("location:userlogin.php?uid=$username");

After:

elseif(($login) > 1){

header("location:userlogin.php?uid=$username");

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