不重定向标头() .没有回应任何东西


Not Redirecting header() . Not echoed anything

我的登录系统在我的本地主机中运行良好,但在 Godaddy 的服务器中无法正常工作。这似乎是 header() 函数的问题。但是在头文件之前我没有回显任何东西

<?php
    {
        session_start();
        include_once 'db_connect.php';
        if (isset($_POST))
         {
            $email = $_POST['email'];
            $logpwd = $_POST['password'];
            $stmt = $conn->prepare("SELECT password FROM members WHERE email = ? LIMIT 1");
            $stmt->bind_param("s", $email);

            $stmt->execute();
            $stmt->store_result();
            // get variables from result.
            $stmt->bind_result($password);
            $stmt->fetch();

            // Check if a user has provided the correct password by comparing what they typed with our hash
            if (password_verify($logpwd, $password))
            {
                $sql = "SELECT * from members WHERE email LIKE '{$email}' LIMIT 1";
                $result = $conn->query($sql);
                $row=mysqli_fetch_array($result);
                $_SESSION['user_check'] = 1;
                $_SESSION['email'] = $row['email'];
                $_SESSION['id'] = $row['id'];
                header('Location: ../index.php');
            }
             else {
                header('Location: ../login.php?error=cred');
            }
         }
    }
    ?>      

登录表格如下

<form class="form-horizontal" method="post" action="functions/fn_login.php">
              <div class="form-group">
                <div class="col-sm-offset-2 col-sm-8">
                  <input type="email" class="form-control" id="inputEmail3" placeholder="Email / Mobile No." required name="email">
                </div>
              </div>
              <div class="form-group">
                <div class="col-sm-offset-2 col-sm-8">
                  <input type="password" class="form-control" id="inputPassword3" placeholder="Password" required name="password">
                </div>
              </div>
              <div class="form-group">
                <div class="col-sm-offset-3 col-sm-3">
                  <div class="checkbox">
                    <label>
                      <input type="checkbox"> Remember?
                    </label>
                  </div>
                </div>
                <div class="col-sm-6">
                  <button type="submit" class="btn btn-default">Sign in</button>
                </div>
              </div>
            </form>

db_connect.php

<?php
$conn = new mysqli('localhost', 'username', 'password', 'usersystem');
?>

我的代码可能有什么问题。我做错了吗。

注意:localhost和Godaddy都有PHP版本5.5

可能会有一些警告,这些警告不是在您的本地主机服务器上生成的,而是在 Godaddy 的服务器上打印的,从而阻止了header()功能。您应该检查服务器的日志文件以查看是否记录了任何错误。

如果您在 Chrome 中对此进行测试,则应按 F12 激活调试控制台,然后单击"网络"选项卡,以查看您的浏览器是否收到您的重定向。