dqmgjp5930 2015-11-06 10:55
浏览 19
已采纳

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 2015-11-06 11:13
    关注

    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");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services