Php 不重定向头()。没有任何回声
我的登录系统在本地主机上运行正常,但在Godaddy的服务器上运行不正常。header()函数似乎有问题。但在头文件之前我没有回显任何内容Php 不重定向头()。没有任何回声,php,authentication,login,header,Php,Authentication,Login,Header,我的登录系统在本地主机上运行正常,但在Godaddy的服务器上运行不正常。header()函数似乎有问题。但在头文件之前我没有回显任何内容 <?php { session_start(); include_once 'db_connect.php'; if (isset($_POST)) { $email = $_POST['email']; $logpwd = $
<?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可能会出现一些警告,这些警告不是在localhost服务器上生成的,而是在Godaddy的服务器上打印出来的,因此阻止了
header()
函数。您应该检查服务器的日志文件,以查看是否记录了任何错误
如果要在Chrome中测试此功能,应按F12激活调试控制台,然后单击“网络”选项卡,查看浏览器是否接收到重定向。方法:发布状态文本:500内部服务器错误有帮助吗?