php标题位置不允许我进入管理区
我最近开始学习PHP。我一直在做一个基本的登录页面。在本地一切都很好,但当它上传到ipage时,它只需重新加载登录页面。如果我输入了错误的登录信息,它会告诉我输入了错误的内容 这是我的密码 login.php:php标题位置不允许我进入管理区,php,login,header,login-script,Php,Login,Header,Login Script,我最近开始学习PHP。我一直在做一个基本的登录页面。在本地一切都很好,但当它上传到ipage时,它只需重新加载登录页面。如果我输入了错误的登录信息,它会告诉我输入了错误的内容 这是我的密码 login.php: <?php ob_start(); session_start(); require 'connect.inc.php'; if (isset($_POST['submit'])) { $uid = $_POST['uid']; $pwd = $_POST['
<?php
ob_start();
session_start();
require 'connect.inc.php';
if (isset($_POST['submit'])) {
$uid = $_POST['uid'];
$pwd = $_POST['pwd'];
$uid = strip_tags($uid);
$pwd = strip_tags($pwd);
$uid = stripcslashes($uid);
$pwd = stripcslashes($pwd);
$uid = mysqli_real_escape_string($db, $uid);
$pwd = mysqli_real_escape_string($db, $pwd);
$sql = "SELECT * FROM users WHERE uid='$uid' LIMIT 1";
$query = mysqli_query($db, $sql);
$row = mysqli_fetch_array($query);
$id = $row['id'];
$db_password = $row['pwd'];
$pwd = password_verify($pwd, $row['pwd']);
if ($pwd == $db_password) {
//$_SESSION['username'] = $uid;
$_SESSION['id'] = $id;
header("Location: http://website.com/dashboard.php");
exit;
}else {
echo 'You didn\'t enter the correct information';
}
}
?>
dashboard.php:
<?php
ob_start();
session_start();
require 'connect.inc.php';
if (!isset($_SESSION['id'])) {
header("Location: http://website.com/login.php");
exit();
}
?>
非常感谢您的帮助……我想您的代码的问题就在这里
if ($pwd == $db_password) {
//$_SESSION['username'] = $uid;
$_SESSION['id'] = $id;
header("Location: http://website.com/dashboard.php");
exit;
}else {
echo 'You didn\'t enter the correct information';
}
password\u verify()
返回TRUE
或FALSE
,您试图检查它是否等于$db\u password
。据我所知,这不会是真的,因此即使您输入的密码是正确的,页面也不会去任何地方,因为if
语句工作不正常
所以在你的情况下,这就是我认为你应该如何拥有你的代码
<?php
ob_start();
session_start();
require 'connect.inc.php';
if (isset($_POST['submit'])) {
$uid = $_POST['uid'];
$pwd = $_POST['pwd'];
$uid = strip_tags($uid);
//$pwd = strip_tags($pwd);
$uid = stripcslashes($uid);
//$pwd = stripcslashes($pwd);
$uid = mysqli_real_escape_string($db, $uid);
//$pwd = mysqli_real_escape_string($db, $pwd);
$sql = "SELECT * FROM users WHERE uid='$uid' LIMIT 1";
$query = mysqli_query($db, $sql);
$row = mysqli_fetch_array($query);
$id = $row['id'];
$db_password = $row['pwd'];
$pwd = password_verify($pwd, $db_password);
if ( $pwd === TRUE ) {
//$_SESSION['username'] = $uid;
$_SESSION['id'] = $id;
header("Location: http://website.com/dashboard.php");
exit;
}else {
echo 'You didn\'t enter the correct information';
}
}
我知道我会后悔这个问题,但是。。。什么是ipage?它是一种托管服务。然后说什么?试试标题(“Location:dashboard.php”)代码>不建议转义密码,尤其是当涉及到诸如123'\abc
等完全有效的密码时。在转义这些时,它会将其重写为123\'\abc
,然后在password\u-verify()
上失败,因为password\u-hash()
被用来存储hash with.Hello。谢谢你的回复。我试过你的编辑。不幸的是,结果是一样的。非常感谢您的回复。我的主机服务出了问题。我想这就是我用廉价主机得到的。感谢所有的投入!