php标题位置不让我进入管理区域

时间:2017-05-13 01:23:43

标签: php login header login-script

我最近开始学习PHP。我一直在做一个基本的登录页面。一切都在本地很好用,但是当它上传到ipage时,它只是重新加载登录页面。如果我输入错误的登录信息,它会告诉我输入错误。

这是我的代码......

的login.php:

visibility

dashboard.php:

<?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';
    }
}


?>

非常感谢任何帮助...

1 个答案:

答案 0 :(得分:0)

我认为您的代码问题在于

password_verify()

TRUE返回FALSE$db_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'; } } 语句不能正常工作。

所以在你的情况下,我认为你应该拥有你的代码

EntryViewModel

string Name
int ArmCount
DateTime DateOfBirth 
bool IsMammal