die('Error: ' . mysql_error()); } $message = "Congratulations " . $new_name . ". Welcome to GameTime!"; $return_arr["success"] = 1; $return_arr["account_type"] = "student"; //add testing deadlines for this user based on the range of testing deadlines $user_id = mysql_insert_id(); //auto-login user upon registration $_SESSION['username'] = $username; $_SESSION['password'] = $password; $_SESSION['loggedIn'] = "true"; $_SESSION['id'] = $user_id; if (isset($hometown)) { $teams = mysql_query("select * from team where name like '%{$hometown}%'"); while ($team = mysql_fetch_array($teams)) { subscribe_user_to_team($team['id']); } } } else { $return_arr["success"] = 0; if (mysql_num_rows($existing_results) > 0 && $passwords_match == TRUE) { $message = "Sorry, this email already has an account. Try again!"; } else { if (mysql_num_rows($existing_results) <= 0 && $passwords_match == FALSE) { $message = "Sorry, the passwords didn't match. Try again!"; } else { if (mysql_num_rows($existing_results) > 0 && $passwords_match == FALSE) { $message = "Sorry, this email already has an account, and the passwords didn't match. Try again!"; } else { if (!filter_var($username, FILTER_VALIDATE_EMAIL)) { $message = "Please enter a properly formatted email address!";
<?php include 'db_connect.php'; include 'helpers.php'; $team_id = $_POST['team_id']; //now we check if this subscription already exists if (user_subscribes_to_team_with_id($team_id) == 1) { //remove entry error_log("removing"); unsubscribe_user_to_team($team_id); echo "unsubscribed"; } else { //add entry error_log("adding"); subscribe_user_to_team($team_id); echo 'subscribed'; }