Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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 > $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();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement