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_guest.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'];
$attendee=$_POST['attendee'];
$ckbanquet=$_POST['ckbanquet'];
$cktour=$_POST['cktour'];
$cktour1=$_POST['cktour1'];
$cktour2=$_POST['cktour2'];
$cktour3=$_POST['cktour3'];
$cktour4=$_POST['cktour4'];
$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="";
$attendee="";
$badgename="";
$ckbanquet="no"; $cktour="no"; $cktour1="no"; $cktour2="no"; $cktour3="no"; $cktour4="no";
}
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'];
$attendee=$_POST['hattendee'];
$badgename=$_POST['hbadgename'];
$regtype=$_POST['hregtype'];
$verifyFlag = "no";
$ckbanquet=$_POST['hckbanquet'];
$cktour=$_POST['hcktour'];
$cktour1=$_POST['hcktour1'];
$cktour2=$_POST['hcktour2'];
$cktour3=$_POST['hcktour3'];
$cktour4=$_POST['hcktour4'];
}
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.="\n\nBadge Name: $badgename";
}
if (strlen($address)) {
$emailmessage.="\n\nAddress:\n$address";
if (strlen($address2)) {
$emailmessage.="\n$address2";
}
}
if (strlen($city) || strlen($state) || strlen($zip)) {
$emailmessage.="\n$city, "."$state $zip";
}
if (strlen($country)) {
$emailmessage.="\n$country";
}
if (strlen($province)) {
$emailmessage.="\n$province";
}
$emailmessage.="\n\nPhone: $phone";
$emailmessage.="\nCell phone: $cell_phone";
// $emailmessage.="\nFax: $fax";
$emailmessage.="\nEmail: $email";
$emailmessage.="\n";
if ($ckbanquet == "yes")
$emailmessage.="\nBanquet: $50.00";
if ($cktour == "yes")
$emailmessage.="\nIndustry Tour (August 31): $75.00";
if ($cktour1 == "yes")
$emailmessage.="\nBadaling Great Wall and Ming Tombs Bus Tour (August 27): $65.00";
if ($cktour2 == "yes")
$emailmessage.="\nTiananmen Square... (August 28): $130.00";
if ($cktour3 == "yes")
$emailmessage.="\nOlympic Green... (August 29): $140.00";
if ($cktour4 == "yes")
$emailmessage.="\nBeijing Old City Day Tour... (August 30): $75.00";
$emailmessage.="\n";
$checkamount = 0;
if ($ckbanquet == "yes")
$checkamount += 50;
if ($cktour == "yes")
$checkamount += 75;
if ($cktour1 == "yes")
$checkamount += 65;
if ($cktour2 == "yes")
$checkamount += 130;
if ($cktour3 == "yes")
$checkamount += 140;
if ($cktour4 == "yes")
$checkamount += 75;
$emailmessage.="\nTotal Due: $";
$emailmessage.="$checkamount";
$emailmessage.="\n\nDate Submitted: ";
$emailmessage.=date("Y M d");
$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_guest.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_guest.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 -- ---------------
?>