dqmgjp5930
dqmgjp5930
2015-11-06 10:55

SERVER在提交CORRECT登录详细信息后显示BLANK WHITE PAGE

已采纳

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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • dsb53973 dsb53973 6年前

    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");
    
    点赞 评论 复制链接分享
  • douzuan2814 douzuan2814 6年前

    In the last elseif condition of your code, try removing the checking of ==1 and then run the code ... if still not working then try and paste the error log file here.

    点赞 评论 复制链接分享