2017-05-13 1 views
0

저는 최근에 PHP를 배우기 시작했습니다. 기본 로그인 페이지에서 작업하고 있습니다. 모든 것이 로컬에서 훌륭하게 작동하지만 ipage에 업로드되면 로그인 페이지가 다시로드됩니다. 잘못된 로그인 정보를 입력하면 잘못된 정보를 입력했음을 알립니다.php 머리글 위치가 나를 관리 구역으로 가게하지 못하게합니다.

여기 내 코드의 ...

login.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'; 
    } 
} 


?> 

dashboard.php :

<?php 
ob_start(); 
session_start(); 
require 'connect.inc.php'; 
if (!isset($_SESSION['id'])) { 

    header("Location: http://website.com/login.php"); 
    exit(); 
} 



?> 

어떤 도움이 아주 많이 주시면 감사하겠습니다 ...

+0

을해야한다고 생각하는 방법이다? – RiggsFolly

+0

그것은 호스팅 서비스입니다. – Zach

+0

http://php.net/manual/en/function.error-reporting.php 및 http://php.net/manual/en/mysqli.error.php는 무엇을 말 했습니까? –

답변

0

나는 당신의 코드 문제가 여기에 있다고 생각한다.

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_verify() 반환 TRUE 또는 FALSE하고 당신이 그것을 $db_password 동일한 경우 확인하기 위해 노력하고 있습니다. 내가 알고있는 것처럼 이것이 사실이 아니므로 입력 한 암호가 맞다고해도 if 문이 제대로 작동하지 않기 때문에 아무데도 페이지가 나타나지 않습니다. 귀하의 경우

그래서

, 이것은 당신이 내가 Ipage이 무엇 나는이 질문을 후회 갈거야 알고 있지만 ... 코드

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

안녕하세요. 당신의 답변에 감사드립니다. 편집을 시도했습니다. 불행히도 결과는 같습니다. – Zach

+0

안녕하세요. 답장을 보내 주셔서 대단히 감사합니다. 결국 호스팅 서비스에 문제가 발생했습니다. 나는 그것이 내가 싼 호스트를 사용하기 위해 얻는 것이라고 생각한다. 모든 의견을 주셔서 감사합니다! – Zach

관련 문제