2013-09-04 3 views
0

현재 축구 리그 용 시스템을 구축 중입니다. 현재 결과를 추가하기 위해 스크립트 파일을 작업하고 있습니다. 대부분의 스크립트가 작동하고 결과는 항상 데이터베이스에 성공적으로 추가됩니다. 그러나 인증 부분은 실패한 것 같습니다. 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는 오류가 없습니다. 이것은 데이터베이스 엔트리가 아니라 인증과 관련이 있기 때문입니다.

+0

'==='help를 사용합니까? – OneOfOne

+0

http://codepad.org/5ISM5cqp도 리디렉션 후에 리디렉션 후/죽기를 원할 경우 재생할 수 없습니다. –

+1

이 성가신 IF의'header()'행을 주석 처리하고 echo가 "true"이면 else 및 echo는 "거짓"이고, else의'}'은'exit();'(특정 것을 테스트하기위한 간단한 코드)를 넣는다. 무엇이 울릴까요? 나는 그것이 "사실"이라고 확신하고 IF가 실제로 "실행되지 않음"이 아님을 알게 될 것입니다 :) – James

답변

1

를 대고 die(); 후 귀하의 비교 코드와 header("Location:...");

0

(라인 12 일부 "만일") 붙여 넣은 일이, 내가이 두 가지 조언 :

  1. 가 주사위를 넣고 (); 또는 exit(); header() 부분 다음에.
  2. 내가 설정 한 위치 경로가 상대적인 동안 header()가 작동하는지 확실하지 않으므로 here을 찾으십시오. 기본적인 조언은 항상 "http://your.site.com/script.php"과 같은 리디렉션에 기본 경로를 사용하는 것입니다.