scholarship = false; $this->cselect = "trv101"; $this->tuition = "1295.00"; } } if ($_POST) $HTTP_VARS = $_POST; else $HTTP_VARS = $_GET; $userdata = new userdata; if (isset($HTTP_VARS["userdata"])) $userdata = unserialize(urldecode($HTTP_VARS["userdata"])); if ( isset($_REQUEST["scholarship"]) ) { $userdata->scholarship = true; $userdata->tuition = "545.00"; } if ( isset($HTTP_VARS["page"]) ) $page = $HTTP_VARS["page"]; else $page = "none"; switch ($page) { case "courses": $userdata->cselect = $HTTP_VARS["cselect"]; if ($HTTP_VARS["back_x"]) { //moving backward echo ""; } else { //moving forward if ($HTTP_VARS["cselect"] == "trv101") {include("enroll/enroll_payment.html"); break;} else if ($HTTP_VARS["cselect"] == "") {$error = "Please select a course before continuing."; include("enroll/enroll_courses.html"); break;} else include("enroll/enroll_othercourses.html"); } break; case "payment": $userdata->payopt = $HTTP_VARS["payopt"]; $userdata->owngen2 = $HTTP_VARS["owngen2"]; if ($HTTP_VARS["back_x"]) { //moving backward include("enroll/enroll_courses.html"); break; } else { //moving forward if ($HTTP_VARS["payopt"] == "cc") include("enroll/enroll_ccnum.html"); else include("enroll/enroll_mobilling.html"); } break; case "ccnum": $userdata->cardnum = $HTTP_VARS["cardnum"]; $userdata->cardname = $HTTP_VARS["cardname"]; $userdata->expmonth = $HTTP_VARS["expmonth"]; $userdata->expyear = $HTTP_VARS["expyear"]; if ($HTTP_VARS["back_x"]) { //moving backward include("enroll/enroll_payment.html"); } else { //moving forward if ($HTTP_VARS["cardname"] == "" || $HTTP_VARS["cardnum"] == "" || $HTTP_VARS["expmonth"] == "" || $HTTP_VARS["expyear"] == "") {$error = "Please fill out all fields."; include("enroll/enroll_ccnum.html"); break;} else if (!checkCCInfo()) {$error = "The card information you entered appears to be invalid. Please check the number and expiration date and try again."; include("enroll/enroll_ccnum.html"); break;} else include("enroll/enroll_ccbilling.html"); } break; case "ccbilling": $userdata->fname = $HTTP_VARS["fname"]; $userdata->lname = $HTTP_VARS["lname"]; $userdata->addr1 = $HTTP_VARS["addr1"]; $userdata->addr2 = $HTTP_VARS["addr2"]; $userdata->city = $HTTP_VARS["city"]; $userdata->state = $HTTP_VARS["state"]; $userdata->zip = $HTTP_VARS["zip"]; $userdata->country = $HTTP_VARS["country"]; $userdata->daytimetel = $HTTP_VARS["daytimetel"]; $userdata->email = $HTTP_VARS["email"]; if ($HTTP_VARS["back_x"]) { //moving backward include("enroll/enroll_ccnum.html"); } else { //moving forward if ($HTTP_VARS["fname"] == "" || $HTTP_VARS["lname"] == "" || $HTTP_VARS["addr1"] == "" || $HTTP_VARS["city"] == "" || $HTTP_VARS["country"] == "" || $HTTP_VARS["daytimetel"] == "" || $HTTP_VARS["email"] == "") {$error = "Please fill out all fields."; include("enroll/enroll_ccbilling.html"); break;} else if (!check_email($HTTP_VARS["email"])) {$error = "The email address you entered appears to be invalid. Please check it and try again."; include("enroll/enroll_ccbilling.html"); break;} else include("enroll/enroll_ccnotify.html"); } break; case "mobilling": $userdata->fname = $HTTP_VARS["fname"]; $userdata->lname = $HTTP_VARS["lname"]; $userdata->addr1 = $HTTP_VARS["addr1"]; $userdata->addr2 = $HTTP_VARS["addr2"]; $userdata->city = $HTTP_VARS["city"]; $userdata->state = $HTTP_VARS["state"]; $userdata->zip = $HTTP_VARS["zip"]; $userdata->country = $HTTP_VARS["country"]; $userdata->daytimetel = $HTTP_VARS["daytimetel"]; $userdata->email = $HTTP_VARS["email"]; if ($HTTP_VARS["back_x"]) { //moving backward include("enroll/enroll_payment.html"); } else { //moving forward if ($HTTP_VARS["fname"] == "" || $HTTP_VARS["lname"] == "" || $HTTP_VARS["addr1"] == "" || $HTTP_VARS["city"] == "" || $HTTP_VARS["country"] == "" || $HTTP_VARS["daytimetel"] == "" || $HTTP_VARS["email"] == "") {$error = "Please fill out all fields."; include("enroll/enroll_mobilling.html"); break;} else if (!check_email($HTTP_VARS["email"])) {$error = "The email address you entered appears to be invalid. Please check it and try again."; include("enroll/enroll_mobilling.html"); break;} else include("enroll/enroll_monotify.html"); } break; case "ccnotify": if ($HTTP_VARS["back_x"]) { //moving backward include("enroll/enroll_ccbilling.html"); } else { //moving forward include("enroll/enroll_checkdata.html"); } break; case "monotify": if ($HTTP_VARS["back_x"]) { //moving backward include("enroll/enroll_mobilling.html"); } else { //moving forward include("enroll/enroll_checkdata.html"); } break; case "agreement": if ($HTTP_VARS["back_x"]) { //moving backward include("enroll/enroll_checkdata.html"); } else { //moving forward if ($userdata->payopt == "cc") include("enroll/enroll_ccsubmit.html"); else include("enroll/enroll_mosubmit.html"); } break; case "checkdata": if ($HTTP_VARS["back_x"]) { //moving backward if ($userdata->payopt == "cc") include("enroll/enroll_ccnotify.html"); else include("enroll/enroll_monotify.html"); } else { //moving forward include("enroll/enroll_agreement.html"); } break; case "dsubmit": if ($HTTP_VARS["back_x"]) { include("enroll/enroll_agreement.html"); } if ($HTTP_VARS["appok_x"]) { if ($userdata->payopt == "cc") include("enroll/enroll_ccform.html"); else include("enroll/enroll_moform.html"); } break; default: include("enroll/enroll_courses.html"); break; } function writevars() { global $userdata; echo ""; return; } function checkCCInfo() { global $HTTP_VARS; //first let's check the exp date $currentmonth = date("m"); $currentyear = date("y"); if ($currentyear > $HTTP_VARS["expyear"]) return false; if (($currentyear == $HTTP_VARS["expyear"]) && ($currentmonth > $HTTP_VARS["expmonth"])) return false; //now the LUN $cardnum = $HTTP_VARS["cardnum"]; //for simplicity $cardnum = str_replace("-", "", $cardnum); $cardnum = str_replace(" ", "", $cardnum); $cardnum = str_replace("/", "", $cardnum); $len = strlen($cardnum); //american express if ($cardnum[0] == "3") if ($len != 15) return false; //Mastercard if ($cardnum[0] == "5") if ($len > 16 || $len < 13) return false; //Visa if ($cardnum[0] == "4") if ($len > 16 || $len < 13) return false; //Discover if ($cardnum[0] == "6") if ($len != 16) return false; $len--; //convert to zero based array type for ($x = $len; $x >= 0; $x -= 2) $checksum += $cardnum[$x]; for ($x = $len - 1; $x >= 0; $x -= 2) { $digit = $cardnum[$x] * 2; if ($digit > 9) $checksum += $digit - 9; else $checksum += $digit; } if ($checksum % 10) return false; else return true; }//end checkCCInfo function check_email($email) { //silly little verification thing... we could also be anal and use DNS $at = strpos($email, "@"); $dot = strpos($email, "."); if (!$at || !$dot) return false; return true; }//end check_email ?>