Advertisement
Guest User

Untitled

a guest
Sep 4th, 2013
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. <?PHP
  2.  
  3. include 'functions.php';
  4. dbConnect();
  5.  
  6. //$userEmail = mysql_real_escape_string($_POST["userEmailText"]);
  7. $userCode = mysql_real_escape_string($_POST["userPasscodeText"]);
  8.  
  9. $authenticated = false;
  10.  
  11. $userEmail = "info@example.com";
  12. if ($userEmail == "info@example.com") {
  13.     header('Location: ../results.php?error=authentication');
  14. }
  15.  
  16. $allUsers = mysql_query("SELECT * FROM accounts WHERE email = '$userEmail'");
  17. while ($thisUser = mysql_fetch_assoc($allUsers)){
  18.     if ($userCode != $thisUser['passCode']) {
  19.         header('Location: ../results.php?error=authentication2');
  20.     }
  21.     echo $thisUser['passCode'];
  22.     $authenticated = true;
  23.     $userID = $thisUser['userID'];
  24. }
  25.  
  26. if (!$authenticated) {
  27.     header('Location: ../results.php?error=authentication3');
  28. }
  29.  
  30. $dateSubmitted = $_POST['submissionDate'];
  31. $homeTeam = $_POST['homeTeam'];
  32. $awayTeam = $_POST['awayTeam'];
  33. $homeGoals = $_POST['homeGoals'];
  34. $awayGoals = $_POST['awayGoals'];
  35.  
  36. if ($homeTeam == $awayTeam) {
  37.     header("Location: ../results.php?error=team");
  38. }
  39.  
  40. if (getTeamLeague($homeTeam) != getTeamLeague($awayTeam)) {
  41.     header("Location: ../results.php?error=league");
  42. } else {
  43.     $leagueID = getTeamLeague($homeTeam);
  44. }
  45.  
  46. if ($homeGoals > $awayGoals) {
  47.     $winnerID = $homeTeam;
  48. } else if ($homeGoals < $awayGoals) {
  49.     $winnerID = $awayTeam;
  50. } else if ($homeGoals == $awayGoals) {
  51.     $winnerID = -1;
  52. }
  53.  
  54. $cQuery = mysql_query("INSERT INTO results VALUES ('', $userID, '$dateSubmitted', $leagueID, $homeTeam, $homeGoals, $awayTeam, $awayGoals, $winnerID, 0)");
  55.  
  56. if ($cQuery){
  57.     header('Location: ../results.php');
  58. } else {
  59.         echo mysql_error();
  60. }
  61.  
  62.  
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement