20120601) {
$typeList[0][0] = "Attendee ($300 USD)";
$typeList[0][1] = "300.00";
$typeList[1][0] = "Student / Retiree ($150 USD)";
$typeList[1][1] = "150.00";
$typeList[2][0] = "Attendee from China ($200 USD)";
$typeList[2][1] = "200.00";
$typeList[3][0] = "Emerging Country Member ($150 USD)";
$typeList[3][1] = "150.00";
$typeList[4][0] = "Exhibit Forum Participant ($350 USD)";
$typeList[4][1] = "350.00";
}
else {
$typeList[0][0] = "Attendee ($250 USD)";
$typeList[0][1] = "250.00";
$typeList[1][0] = "Student / Retiree ($100 USD)";
$typeList[1][1] = "100.00";
$typeList[2][0] = "Attendee from China ($150 USD)";
$typeList[2][1] = "150.00";
$typeList[3][0] = "Emerging Country Member ($100 USD)";
$typeList[3][1] = "100.00";
$typeList[4][0] = "Exhibit Forum Participant ($300 USD)";
$typeList[4][1] = "300.00";
}
//
// validform()- check that field entries are valid before processing
//
function validform() {
global $errMessage; $err;
global $firstname, $middlename, $lastname, $email;
global $passport, $p_dob_mm, $p_dob_dd, $p_dob_yyyy;
global $p_issue_mm, $p_issue_dd, $p_issue_yyyy, $p_expiration_mm, $p_expiration_dd, $p_expiration_yyyy;
global $p_authority, $p_country;
global $airline, $flight, $arrival_mm, $arrival_dd, $arrival_yyyy, $arrival_time;
global $address, $city, $state, $zip, $country, $badgename;
$err = 0;
// Check for required fields
if (empty($firstname) || empty($lastname)) {
$errMessage = "\n** Required Name field missing\n";
return 0;
}
else if (empty($email)) {
$errMessage = "\n** Required E-mail field missing\n";
return 0;
}
else if ( !($result=ereg("^[^@ ]+@[^@ ]+\.[^@ ]+$",$email,$trashed)) ) {
$errMessage = "\n** Please enter a valid E-mail address\n";
return 0;
}
if (empty($address)) {
$errMessage = "\n** Required Address field missing\n";
return 0;
}
if (empty($city)) {
$errMessage = "\n** Required City field missing\n";
return 0;
}
if ( ( ($country == "USA") || ($country == "US") || ($country == "U.S.A.") || ($country == "U.S.") ||
($country == "United States") || ($country == "United States of America") ) && empty($state)) {
$errMessage = "\n** Required State field missing\n";
return 0;
}
if (empty($country)) {
$errMessage = "\n** Required Country field missing\n";
return 0;
}
// Validate date fields
if (!empty($passport)) {
// Validate date fields
if ( ($p_dob_mm > 12 || $p_dob_mm < 1) || ($p_dob_dd > 31 || $p_dob_dd < 1) || ($p_dob_yyyy < 1910 || $p_dob_yyyy > 2099)) {
$errMessage = "Invalid or Missing Passport date of birth, please correct";
return 0;
}
if (($p_issue_mm > 12 || $p_issue_mm < 1) || ($p_issue_dd > 31 || $p_issue_dd < 1) || ($p_issue_yyyy < 1910 || $p_issue_yyyy > 2099)) {
$errMessage = "Invalid or Missing Passport issue date, please correct";
return 0;
}
if (($p_expiration_mm > 12 || $p_expiration_mm < 1) || ($p_expiration_dd > 31 || $p_expiration_dd < 1) || ($p_expiration_yyyy < 1910 || $p_expiration_yyyy > 2099)) {
$errMessage = "Invalid or Missing Passport expiration date, please correct";
return 0;
}
if (empty($p_country)) {
$errMessage = "\n** Country Issuing Passport missing\n";
return 0;
}
}
if (!empty($airline)) {
if (empty($flight)) {
$errMessage = "Missing Flight number, please correct";
return 0;
}
if (($arrival_mm > 12 || $arrival_mm < 01) || ($arrival_dd > 31 || $arrival_dd < 01) ||
($arrival_yyyy < 1910 || $arrival_yyyy > 2099)) {
$errMessage = "Invalid Flight arrival date, please correct";
return 0;
}
}
return 1;
}
// RESET button - return to original form
if ($_POST['reset']) {
header("Location: http://www.swst.org/meetings/AM12/regform.html");
}
// Retrieve Form input fields
if ($_POST['continue']) {
$firstname=$_POST['firstname'];
$middlename=$_POST['middlename'];
$lastname=$_POST['lastname'];
$passport=$_POST['passport'];
$p_dob_mm=$_POST['p_dob_mm'];
$p_dob_dd=$_POST['p_dob_dd'];
$p_dob_yyyy=$_POST['p_dob_yyyy'];
$p_issue_mm=$_POST['p_issue_mm'];
$p_issue_dd=$_POST['p_issue_dd'];
$p_issue_yyyy=$_POST['p_issue_yyyy'];
$p_expiration_mm=$_POST['p_expiration_mm'];
$p_expiration_dd=$_POST['p_expiration_dd'];
$p_expiration_yyyy=$_POST['p_expiration_yyyy'];
$p_country=$_POST['p_country'];
$p_authority=$_POST['p_authority'];
$airline=$_POST['airline'];
$flight=$_POST['flight'];
$arrival_mm=$_POST['arrival_mm'];
$arrival_dd=$_POST['arrival_dd'];
$arrival_yyyy=$_POST['arrival_yyyy'];
$arrival_time=$_POST['arrival_time'];
$title=$_POST['title'];
$jobtitle=$_POST['jobtitle'];
$compname=$_POST['compname'];
$address=$_POST['address'];
$address2=$_POST['address2'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$country=$_POST['country'];
$province=$_POST['province'];
$phone=$_POST['phone'];
$cell_phone=$_POST['cell_phone'];
$fax=$_POST['fax'];
$email=$_POST['email'];
$attendeeType=$_POST['attendeeType'];
$badgename=$_POST['badgename'];
$regtype=$_POST['regtype'];
$verifyFlag=$_POST['verifyFlag'];
}
if ( (!($_POST['continue'])) && (!($_POST['goback']))&& (!($_POST['mailcheck'])) && (!($_POST['submit'])) ){
// Define Form input fields default values
$country="";
$firstname="";
$middlename="";
$lastname="";
$passport="";
$p_dob_mm="";$p_dob_dd="";$p_dob_yyyy="";
$p_issue_mm="";$p_issue_dd="";$p_issue_yyyy="";
$p_expiration_mm="";$p_expiration_dd="";$p_expiration_yyyy="";
$p_country="";
$p_authority="";
$airline="";
$flight="";
$arrival_mm="";$arrival_dd="";$arrival_yyyy="";
$arrival_time="";
$title="";
$jobtitle="";
$compname="";
$address=""; $address2="";
$city="";
$state="";
$zip="";
$province="";
$phone="";
$cell_phone="";
$fax="";
$email="";
$attendeeType="0";
$badgename="";
}
if ($_POST['goback']) {
// Get form field values from hidden fields
$firstname=$_POST['hfirstname'];
$middlename=$_POST['hmiddlename'];
$lastname=$_POST['hlastname'];
$passport=$_POST['hpassport'];
$p_dob_mm=$_POST['hp_dob_mm'];$p_dob_dd=$_POST['hp_dob_dd'];$p_dob_yyyy=$_POST['hp_dob_yyyy'];
$p_issue_mm=$_POST['hp_issue_mm'];$p_issue_dd=$_POST['hp_issue_dd'];$p_issue_yyyy=$_POST['hp_issue_yyyy'];
$p_expiration_mm=$_POST['hp_expiration_mm'];$p_expiration_dd=$_POST['hp_expiration_dd'];
$p_expiration_yyyy=$_POST['hp_expiration_yyyy'];
$p_country=$_POST['hp_country'];
$p_authority=$_POST['hp_authority'];
$airline=$_POST['hairline'];
$flight=$_POST['hflight'];
$arrival_mm=$_POST['harrival_mm'];$arrival_dd=$_POST['harrival_dd'];
$arrival_yyyy=$_POST['harrival_yyyy'];
$arrival_time=$_POST['harrival_time'];
$title=$_POST['htitle'];
$jobtitle=$_POST['hjobtitle'];
$compname=$_POST['hcompname'];
$address=$_POST['haddress'];
$address2=$_POST['haddress2'];
$city=$_POST['hcity'];
$state=$_POST['hstate'];
$zip=$_POST['hzip'];
$country=$_POST['hcountry'];
$province=$_POST['hprovince'];
$phone=$_POST['hphone'];
$cell_phone=$_POST['hcell_phone'];
$fax=$_POST['hfax'];
$email=$_POST['hemail'];
$attendeeType=$_POST['hattendeeType'];
$badgename=$_POST['hbadgename'];
$regtype=$_POST['hregtype'];
$verifyFlag = "no";
}
if ($_POST['mailcheck']) {
// Applicant wants to mail a check rather than pay online
$emailmessage.="\nUser selected Pay By Check\n";
header("Location: http://www.swst.org/meetings/AM12/regPayByCheck.html");
}
// CONTINUE button before final verification by user.
// Save registration fields for email once payment is processed.
if ( ($_POST['continue']) && ($verifyFlag == "no") ) {
if (validform()) {
$verifyFlag = "yes";
// Once all form data is validated, setup EMAIL to be sent to SWST once PayPal
// processing is complete (notify_url, see PayPal button). Email string is
// stored on host in mysql database since we can't be guaranteed the user
// will return to SWST site, and PayPal doesn't keep SWST session data.
//
// $emailmessage is also a session variable that can be accessed by the Pay by Check page.
//
if (strlen($title))
$emailmessage.="\n$title $firstname $middlename $lastname";
else
$emailmessage.="\n$firstname $middlename $lastname";
if (strlen($passport)) {
$emailmessage.="\n\nPassport: $passport";
$emailmessage.="\nDate of birth: $p_dob_mm-$p_dob_dd-$p_dob_yyyy";
$emailmessage.="\nIssue date: $p_issue_mm-$p_issue_dd-$p_issue_yyyy";
$emailmessage.="\nExpiration date: $p_expiration_mm-$p_expiration_dd-$p_expiration_yyyy";
$emailmessage.="\nCountry of issue: $p_country";
$emailmessage.="\nAuthority or place of issue: $p_authority";
}
if (strlen($airline) || strlen($flight)) {
$emailmessage.="\n\nAirline:\n$airline $flight";
$emailmessage.="\nArrival: $arrival_mm-$arrival_dd-$arrival_yyyy $arrival_time";
}
if (strlen($badgename)) {
$emailmessage.="\nBadge Name: $badgename\n";
}
if (strlen($jobtitle))
$emailmessage.="\n$jobtitle";
$emailmessage.="\nCompany/Institution: $compname";
$emailmessage.="\n\nAddress:\n$address";
if (strlen($address2)) {
$emailmessage.="\n$address2";
}
$emailmessage.="\n$city, "."$state $zip";
if (strlen($country)) {
$emailmessage.="\n$country";
}
if (strlen($province)) {
$emailmessage.="\n$province";
}
$emailmessage.="\n\nPhone: $phone";
$emailmessage.="\nCell: $cell_phone";
$emailmessage.="\nFax: $fax";
$emailmessage.="\n$email";
$emailmessage.="\n";
$checkamount = $typeList[$attendeeType][1];
$emailmessage.="\nTotal Due: $";
$emailmessage.="$checkamount";
$emailmessage.="\n\nDate Submitted: ";
$emailmessage.=date("Y M d");
$emailmessage.="\n\nEvents and banquet tickets are available for all guests.\nIf you are not from China and are planning to take one or more guests to the convention, each guest must register passport information.\n\nRegister guest(s) at http://www.swst.org/meetings/AM12/regform_guest.html\n";
$emailmessage.="\n";
$registrantname = "$firstname $middlename $lastname";
// If needed, we use the check amount in regPayByCheck to display to user
// If user chooses to Mail Check, then we send the email to SWST from the Mail Check screen
$_SESSION['checkamount'] = $checkamount ;
$_SESSION['registrantname'] = $registrantname;
$_SESSION['registrantemail'] = $email;
$_SESSION['emailmessage'] = $emailmessage ;
// Save email Message in Mysql database so we can send it when PayPal notifies us that payment was completed.
// Note: pressing the PayPal button causes all SESSION data to be lost, but we can't send the email the in case
// the user decides not to complete payment in PayPal
//
// Connect to server and select database.
// We store the registration form email as a string in a simple
// mysql database. When PayPal's Instant Payment Notification (IPN)
// calls the swst url (see notify_url), the applicant has submitted final payment
// and it's safe to send the registration form email to SWST.
$host="localhost"; // Host name
$username="swstorg_Beth"; // Mysql username
$password="swstNew"; // Mysql password
$db_name="swstorg_sessionEmail"; // Database name
$tbl_name="registrationEmail"; // Table name
if ( !($link=mysql_connect($host, $username, $password)) ) {
$emailmessage .= "\ninvalid link mysql_connect in 2012 regform.html\n";
mail($senderrorstoemail, $emailerrorsubject, $emailmessage, "From: \"$fromname\" $fromemail\n");
//or die("cannot connect because: ".mysql_error());
}
else {
if (!($dbselected = mysql_select_db("swstorg_sessionEmail", $link)) ) {
$emailmessage .= "\nfailed mysql_select in 2012 regform.html\n";
mail($senderrorstoemail, $emailerrorsubject, $emailmessage, "From: \"$fromname\" $fromemail\n");
//or die("cannot select DB: ".mysql_error());
}
}
if ($dbselected) {
$sessionid = md5(session_id());
$submitted = date("Ymd h:i:s A");
// make sure current session id is removed for this user
mysql_query("DELETE FROM registrationEmail WHERE sessionID = '$sessionid'", $link);
// TESTING
//mysql_query("INSERT INTO registrationEmail (sessionID, emailString, submitted)
// VALUES('987655','THIS is a TEST string', '$submitted' ) ");
$myrc = mysql_query("INSERT INTO registrationEmail (sessionID, emailString, submitted)
VALUES ('$sessionid', '$emailmessage', '$submitted')");
mysql_close($link);
}
// ------------------------------------------
// End database update with email string.
}
}
//-- ------------- END PHP LOGIN FORM PROCESSING -- ---------------
?>