PHP와 세션에 문제가 있습니다. 이것은 dictionary.php에 대한 나의 코드입니다.PHP 세션 문제
<?php
if(!isset($_SESSION['auth'])){
$_SESSION['auth'] = 0;
}
if($_SESSION['auth'] == 0){
header("Location: index.php");
}
?>
그래서, 거기에 0 또는 1로 세션 "인증"으로 설정하도록되어 index.php에 있습니다 :
<?php
$msg = "";
//Password handler
if(!isset($_POST['password'])){
$password = "";
}else{
$password = $_POST['password'];
}
if(!isset($_SESSION['auth'])){
$_SESSION['auth'] = 0;
}
//Username handler
if(!isset($_POST['username'])){
$username = "";
}else{
$username = $_POST['username'];
if($username == "potato" && $password == "poteto"){
$_SESSION['auth'] = 1;
header("Location: dictionary.php");
}else{
$msg = "<br />
<font color=\"#FF0000\">Invalid username or password!</font><br />";
}
}
if($_SESSION['auth'] == 0){
header("Location: dictionary.php");
}
?>
(위의 수 있습니다 잘못된 관행이나 뭐,하지만 난 단지 학교 프로젝트를 위해이 일을하고 난 파일 dictionary.php을보고 다른 사람을 원하지 않는다.)
의 index.php는 경우 당신이 천국에 $username
및 $password
을 보낼 POST 방법과 양식을 사용합니다 ' 아직 눈치 채지 못했다.
로그인 정보 "감자"와 "poteto"를 입력하면 dictionary.php로 리다이렉트되지만, 즉시 index.php로 다시 보내집니다. 위의 코드를 수정 해 보았지만 행운은 없습니다.
누구든지 나를 보여줘야한다면 URL을 제공 할 수 있습니다.
감사합니다.
어디에도'session_start()'가 보이지 않습니다. 먼저 수정하십시오. 읽기 : http://php.net/manual/en/session.examples.basic.php –
"오류 310 (net :: ERR_TOO_MANY_REDIRECTS) : 리디렉션이 너무 많습니다." – Raymonf
@RBLXDev : 리다이렉트 루프를 만들었습니다. 그것들은 문제를 해결하는 것이 덜 쉽지만, 무엇이 도움이되는지, 지금 문제를 해결해야합니다. – hakre