현재 축구 리그 용 시스템을 구축 중입니다. 현재 결과를 추가하기 위해 스크립트 파일을 작업하고 있습니다. 대부분의 스크립트가 작동하고 결과는 항상 데이터베이스에 성공적으로 추가됩니다. 그러나 인증 부분은 실패한 것 같습니다. 12 행의 if 문이 실행되지 않는 것 같아서 이유를 이해할 수 없습니다.PHP 문이 실행되지 않는 경우
내 코드는 여기에 페이스트 빈 링크에서 찾을 수 있습니다 http://pastebin.com/ty4pdGgn
<?PHP
include 'functions.php';
dbConnect();
//$userEmail = mysql_real_escape_string($_POST["userEmailText"]);
$userCode = mysql_real_escape_string($_POST["userPasscodeText"]);
$authenticated = false;
$userEmail = "[email protected]";
if ($userEmail == "[email protected]") {
header('Location: ../results.php?error=authentication');
}
$allUsers = mysql_query("SELECT * FROM accounts WHERE email = '$userEmail'");
while ($thisUser = mysql_fetch_assoc($allUsers)){
if ($userCode != $thisUser['passCode']) {
header('Location: ../results.php?error=authentication2');
}
echo $thisUser['passCode'];
$authenticated = true;
$userID = $thisUser['userID'];
}
if (!$authenticated) {
header('Location: ../results.php?error=authentication3');
}
$dateSubmitted = $_POST['submissionDate'];
$homeTeam = $_POST['homeTeam'];
$awayTeam = $_POST['awayTeam'];
$homeGoals = $_POST['homeGoals'];
$awayGoals = $_POST['awayGoals'];
if ($homeTeam == $awayTeam) {
header("Location: ../results.php?error=team");
}
if (getTeamLeague($homeTeam) != getTeamLeague($awayTeam)) {
header("Location: ../results.php?error=league");
} else {
$leagueID = getTeamLeague($homeTeam);
}
if ($homeGoals > $awayGoals) {
$winnerID = $homeTeam;
} else if ($homeGoals < $awayGoals) {
$winnerID = $awayTeam;
} else if ($homeGoals == $awayGoals) {
$winnerID = -1;
}
$cQuery = mysql_query("INSERT INTO results VALUES ('', $userID, '$dateSubmitted', $leagueID, $homeTeam, $homeGoals, $awayTeam, $awayGoals, $winnerID, 0)");
if ($cQuery){
header('Location: ../results.php');
} else {
echo mysql_error();
}
?>
은이 문제에 어떤 도움이 많이 이해할 수있을 것이다. functions.php는 오류가 없습니다. 이것은 데이터베이스 엔트리가 아니라 인증과 관련이 있기 때문입니다.
'==='help를 사용합니까? – OneOfOne
http://codepad.org/5ISM5cqp도 리디렉션 후에 리디렉션 후/죽기를 원할 경우 재생할 수 없습니다. –
이 성가신 IF의'header()'행을 주석 처리하고 echo가 "true"이면 else 및 echo는 "거짓"이고, else의'}'은'exit();'(특정 것을 테스트하기위한 간단한 코드)를 넣는다. 무엇이 울릴까요? 나는 그것이 "사실"이라고 확신하고 IF가 실제로 "실행되지 않음"이 아님을 알게 될 것입니다 :) – James