function app_start() { // Create a new instance of the Session object, and get the channel information. $session = new Session(); $from_info = $session->getFrom(); $network = $from_info['channel']; // Create a new instance of the Tropo object. $tropo = new Tropo(); // See if any text was sent with session start. $initial_text = $session->getInitialText(); // If the initial text is a zip code, skip the input collection and go right to results. if (strlen($initial_text) == 1 && is_numeric($initial_text)) { valid_text($tropo, $initial_text); } else { // Welcome prompt. $tropo->say("Welcome to the Tropo PHP example for {$network}"); // Set up options for input. $options = array("attempts" => 3, "bargein" => true, "choices" => "1,2,3,4", "mode" => "dtmf", "name" => "movie", "timeout" => 30); // Ask the caller for input, pass in options. $tropo->ask("Which of these trilogies do you like the best? Press 1 to vote for Lord of the Rings, press 2 for the original Star Wars, 3 for the Star Wars prequels, or press 4 for the Matrix", $options); // Tell Tropo what to do when the user has entered input, or if there's a problem. This redirects to the instructions under dispatch_post('/choice', 'app_choice') or dispatch_post('/incomplete', 'app_incomplete'). $tropo->on(array("event" => "continue", "next" => "favorite-movie-webapi.php?uri=choice", "say" => "Please hold.")); $tropo->on(array("event" => "incomplete", "next" => "favorite-movie-webapi.php?uri=incomplete")); } // Render the JSON for the Tropo WebAPI to consume. return $tropo->RenderJson(); }
public function formValidation() { if ($_POST['boardMemberFirstName']) { if (strlen($_POST['boardMemberFirstName']) < 2) { $this->boardMemberFormErrors[] = "First name must be at least 2 characters long."; } if (!valid_text($_POST['boardMemberFirstName'])) { $this->boardMemberFormErrors[] = "First name contains invalid characters. Check for quotes."; } } else { $this->boardMemberFormErrors[] = "First name is a required field"; } if ($_POST['boardMemberLastName']) { if (strlen($_POST['boardMemberLastName']) < 2) { $this->boardMemberFormErrors[] = "Last name must be at least 2 characters long."; } if (!valid_text($_POST['boardMemberLastName'])) { $this->boardMemberFormErrors[] = "Last name contains invalid characters. Check for quotes."; } } else { $this->boardMemberFormErrors[] = "Last name is a required field"; } if ($_POST['boardMemberEmail']) { if (validate_email(format_trim($_POST['boardMemberEmail']))) { //Do nothing } else { $this->boardMemberFormErrors[] = "Email is not valid."; } } if (isset($_FILES['boardMemberImage']['type']) && $_FILES['boardMemberImage']['size'] > 0) { if ($_FILES['boardMemberImage']['type'] != 'image/jpeg' && $_FILES['boardMemberImage']['type'] != 'image/gif') { $this->boardMemberFormErrors[] = "Board member image can only be a GIF or JPEG. Attempted file is '" . $_FILES['boardMemberImage']['type'] . "'."; } } return $this->get_boardMemberFormErrors(); }
function validate_seasonregistration_form() { $errors = array(); #Firstname Validation if (isset($_POST['firstname']) && $_POST['firstname']) { if (strlen($_POST['firstname']) < 2) { $errors[] = "First name must be at least 2 characters long."; } if (!valid_text($_POST['firstname'])) { $errors[] = "First name contains invalid characters. Check for quotes."; } } else { $errors[] = "First name is a required field"; } #Lastname Validation if (isset($_POST['lastname']) && $_POST['lastname']) { if (strlen($_POST['lastname']) < 2) { $errors[] = "Last name must be at least 2 characters long."; } if (!valid_text($_POST['lastname'])) { $errors[] = "Last name contains invalid characters. Check for quotes."; } } else { $errors[] = "Last name is a required field"; } #Address One Validation if (isset($_POST['addressOne']) && $_POST['addressOne']) { //Do nothing .. Not doing any AVS checks, so hopefully they give us a good address } else { $errors[] = "Address Field One is required"; } #City Validation if (isset($_POST['city']) && $_POST['city']) { //Do nothing .. Not doing any AVS checks, so hopefully they give us a good city } else { $errors[] = "City is required"; } #State Validation if (isset($_POST['state']) && $_POST['state']) { //Do nothing .. Not doing any AVS checks, so hopefully they give us a good state } else { $errors[] = "State is required"; } #Postal Code Validation if (isset($_POST['postalCode']) && $_POST['postalCode']) { //Do nothing .. Not doing any AVS checks, so hopefully they give us a good zip } else { $errors[] = "Zipcode is required"; } #Email Validation if (isset($_POST['email']) && $_POST['email']) { if (validate_email(format_trim($_POST['email']))) { //Do nothing .. its a valid email, i guess } else { $errors[] = "Email is not valid."; } } #Position Validation if (isset($_POST['goalie']) && $_POST['goalie'] == "on" || isset($_POST['defense']) && $_POST['defense'] == "on" || isset($_POST['center']) && $_POST['center'] == "on" || isset($_POST['wing']) && $_POST['wing'] == "on") { //Do nothing .. At least one position is checked } else { $errors[] = "Must provide at least one position you would like to play. (Goalie, Defense, Center, Wing)"; } #Jersey Information Validation #Jersey Choice 1 Validation //(isset($_POST['jerseyNumChoiceTwo']) && $_POST['jerseyNumChoiceTwo']) || $_POST['jerseyNumChoiceTwo'] == 0 if (isset($_POST['jerseyNumChoiceOne']) && $_POST['jerseyNumChoiceOne'] > -1 || $_POST['jerseyNumChoiceOne'] == 0) { //if (is_numeric($_POST['jerseyNumChoiceOne']) && is_int(intval($_POST['jerseyNumChoiceOne']))) { if (strlen($_POST['jerseyNumChoiceOne']) == strlen(intval($_POST['jerseyNumChoiceOne']))) { if (intval($_POST['jerseyNumChoiceOne']) < 0 || intval($_POST['jerseyNumChoiceOne']) > 99) { $errors[] = "Jersey Number Choice 1 must be between 0 - 99."; } } else { $errors[] = "Must provide a valid jersey number for Choice 1. (0 - 99)"; } } else { $errors[] = "Must provide a valid jersey number for Choice 1. (0 - 99)"; } #Jersey Choice 2 Validation if (isset($_POST['jerseyNumChoiceTwo']) && $_POST['jerseyNumChoiceTwo'] > -1 || $_POST['jerseyNumChoiceTwo'] == 0) { if (strlen($_POST['jerseyNumChoiceTwo']) == strlen(intval($_POST['jerseyNumChoiceTwo']))) { if (intval($_POST['jerseyNumChoiceTwo']) < 0 || intval($_POST['jerseyNumChoiceTwo']) > 99) { $errors[] = "Jersey Number Choice 2 must be between 0 - 99."; } } else { $errors[] = "Must provide a valid jersey number for Choice 2. (0 - 99)"; } } else { $errors[] = "Must provide a valid jersey number for Choice 2. (0 - 99)"; } #Jersey Choice 3 Validation if (isset($_POST['jerseyNumChoiceThree']) && $_POST['jerseyNumChoiceThree'] > -1 || $_POST['jerseyNumChoiceThree'] == 0) { if (strlen($_POST['jerseyNumChoiceThree']) == strlen(intval($_POST['jerseyNumChoiceThree']))) { if (intval($_POST['jerseyNumChoiceThree']) < 0 || intval($_POST['jerseyNumChoiceThree']) > 99) { $errors[] = "Jersey Number Choice 3 must be between 0 - 99."; } } else { $errors[] = "Must provide a valid jersey number for Choice 3. (0 - 99)"; } } else { $errors[] = "Must provide a valid jersey number for Choice 3. (0 - 99)"; } #Will Sub? Validation if (isset($_POST['willSub']) && $_POST['willSub'] == "Y") { if (isset($_POST['sunSub']) && $_POST['sunSub'] == "on" || isset($_POST['monSub']) && $_POST['monSub'] == "on" || isset($_POST['tueSub']) && $_POST['tueSub'] == "on" || isset($_POST['wedSub']) && $_POST['wedSub'] == "on" || isset($_POST['thuSub']) && $_POST['thuSub'] == "on" || isset($_POST['friSub']) && $_POST['friSub'] == "on" || isset($_POST['satSub']) && $_POST['satSub'] == "on") { //Do nothing, they picked a day that they can sub } else { $errors[] = "Since you answered yes to: Will you sub?, you must indicate at least one day you are willing to sub."; } } else { //Do nothing .. they indicated "NO" for Will they sub? } #Return Errors return $errors; }
function validate_registration_form() { $errors = array(); if ($_POST['firstname']) { if (strlen($_POST['firstname']) < 2) { $errors[] = "First name must be at least 2 characters long."; } if (!valid_text($_POST['firstname'])) { $errors[] = "First name contains invalid characters. Check for quotes."; } } else { $errors[] = "First name is a required field"; } if ($_POST['lastname']) { if (strlen($_POST['lastname']) < 2) { $errors[] = "Last name must be at least 2 characters long."; } if (!valid_text($_POST['lastname'])) { $errors[] = "Last name contains invalid characters. Check for quotes."; } } else { $errors[] = "Last name is a required field"; } if ($_POST['password'] || $_POST['password2']) { if (strlen($_POST['password']) < 4 || strlen($_POST['password']) >= 10) { $errors[] = "Please choose a password between 4-10 characters in length."; } if ($_POST['password'] != $_POST['password2']) { $errors[] = "Password and Confirmation Password do not match."; } } else { $errors[] = "Must provide password and confirmation password."; } if ($_POST['email']) { if (validate_email(format_trim($_POST['email']))) { //Do nothing } else { $errors[] = "Email is not valid."; } } else { $errors[] = "Must provide a valid email address."; } if (count($errors) > 0) { global $Link; $uname = $_POST['email']; $check_user_query = "SELECT eMail, accessLevel FROM " . USER . " WHERE eMail='" . $uname . "' AND accessLevel > 0"; $check_result = mysql_query($check_user_query, $Link); if ($check_result && mysql_num_rows($check_result) > 0) { $errors[] = 'Email already exists. Please choose a different one.'; } } return $errors; }