Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP If Statements Not Firing
    primarykey
    data
    text
    <p>I'm currently building a system for a football league. And are currently working on the script file for adding results. Most of the script works and the result is always successfully added to the database. However the authentication part seems to fail. The if statement on line 12 does not seem to fire and I can't understand why.</p> <p>My code can be found in the pastebin link here: <a href="http://pastebin.com/ty4pdGgn" rel="nofollow">http://pastebin.com/ty4pdGgn</a></p> <pre><code>&lt;?PHP include 'functions.php'; dbConnect(); //$userEmail = mysql_real_escape_string($_POST["userEmailText"]); $userCode = mysql_real_escape_string($_POST["userPasscodeText"]); $authenticated = false; $userEmail = "info@example.com"; if ($userEmail == "info@example.com") { 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 &gt; $awayGoals) { $winnerID = $homeTeam; } else if ($homeGoals &lt; $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(); } ?&gt; </code></pre> <p>Any help with this matter will be much appreciated. The functions.php contains no errors as this is all to do with database entry and not the authentication.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload