";
$err = true;
} //end first name if
//check middle name alpha whitespace and . and -
if ((preg_match('/[^_a-zA-Z\s.-]/', $mi)) || ($mi == '')){
$reportF = $reportF . "chr(240)mi:$mi";
$err = true;
}//end middle initial validation if
//check last name alpha whitespace and . - allowered
if ((preg_match('/[^_a-zA-Z\s.-]/', $last)) || ($last == '')){
$reportF = $reportF . "chr(240)last:$last";
$err = true;
} //end last name if
//check passwords alpha numerics allowed, compare the two entries and then check strlen
if ( (preg_match('/[^_a-zA-Z0-9]/', $pass)) || (strcmp($pass, $pass1) !=0 ) || (strlen($pass) < 4) || (strlen($pass) > 12) ) {
$reportF = $reportF . "chr(240)pass:$pass";
$reportF = $reportF . "chr(240)pass1:$pass1";
$err = true;
} //end password iff
//check email this regular expression isn't mine, I got it from a newsgroup
if (!(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$", $contact)) && ($contact != '')){
$reportF = $reportF . "chr(240)contact:$contact";
$err = true;
} //end email if
//check date of graduation must be in MM/YYYY format
if(!(preg_match('/([0-9\s]{1,2})\/([0-9\s]{4})/',$yog)) && ($yog != '')){//backwards
$reportF = $reportF . "chr(240)yog:$yog";
$err = true;
} //end yog if
//validate Question input, alphanumerics whitespace _. ? ! and - allowed
if ((preg_match('/[^_a-zA-Z0-9\s.?!-]/', $quest)) || ($quest == '')){
$reportF = $reportF . "chr(240)quest:$quest";
$err = true;
} //end quest if
//check answer alphanumerics whitespace . _ and - allowed
if ((preg_match('/[^_a-zA-Z0-9\s.-]/', $answer)) || ($answer == '')){
$reportF = $reportF . "chr(240)answer:$answer";
$err = true;
} //end ans if
//check address alphanumerics _ whitespace #. and - allowed
if ((preg_match('/[^_a-zA-Z0-9\s#.-]/', $add)) || ($add == '')){
$reportF = $reportF . "chr(240)add:$add";
$err = true;
} //end Address if
//check Degree for alpha whitespace _ . and - address
if ((preg_match('/[^_a-zA-Z\s.-]/', $deg)) || ($deg == '')){
$reportF = $reportF . "chr(240)deg:$deg";
$err = true;
} //end degree if
//check the city for alphanumeric whitespace _ . and - address
if ((preg_match('/[^_a-zA-Z0-9\s.-]/', $city)) || ($city == '')){
$reportF = $reportF . "chr(240)city:$city";
$err = true;
} //end city if
//check state for alpha whitespace . and - address
if ((preg_match('/[^a-zA-Z\s.-]/', $state)) || ($state == '')){
$reportF = $reportF . "chr(240)state:$state";
$err = true;
} //end state if
//check for zipcode numeric whitespace and - address
if ($zip == ''){
$reportF = $reportF . "chr(240)zip:$zip";
$err = true;
}
if($reportF != "doh:doh") { //there were errors format and print out the error screen
$errorLine = explode("chr(240)",$reportF);
headHTML();
print "There were errors in your request.
The bad entries are marked with an
:
";
firstpart($reportF,$err);
} else {
if($err == "start" || $err == "false"){
//no error in data validation
if (!$conn = new COM("ADODB.Connection")) {
exit("Unable to create an ADODB connection
");
}
//end connection if
$strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("r.mdb");
$conn->open($strConn);
$strSQL = "INSERT INTO reqs(username,first,mi,last,yog,contact,quest,answer,password,degree,add,city,state,zip) VALUES ('$user','$first', '$mi', '$last', '$yog', '$contact','$quest', '$answer','$pass','$contact','$add','$city','$state','$zip')";
$rs = $conn->execute($strSQL);
if((!$rs) || ($last == "Logging_Check")) {
//check for errors on the insert
print "There were errors with your request. They have been logged for admins
";
$temp= date("Ymdhis", mktime());
$filename = "$temp.txt";
//start of dump the variables to a file
ob_start();
var_dump($GLOBALS);
$output = ob_get_contents();
ob_end_clean();
if (!$handle = fopen($filename, 'w')) {
print "Cannot open file ($filename)";
exit;
}
if (!fwrite($handle, $output)) {
print "Cannot write to file ($filename)";
exit;
}
fclose($handle);
print "Please email bogus@cs.edu with your desired username, first, middle and last name so the account may be create manually.
Sorry for any inconvience.";
print "";
mail("mike@nmu.edu", "Account Request had errors for $first $mi $last", "An Account Request for $user has had errors from $first $mi $last Check error log for $temp.txt.","From: here@here.nmu.edu\r\n");
} else{
print "Your request has been put in queue\n";
print "The values are username:$user
";
print "Name: $first $mi $last\n
";
print "Password (case sensitive!) $pass
\n";
print "Date of Graduation: $yog\n
";
print "Password hint question: $quest
\n";
print "Password hint answer: $answer\n
";
print "Contact Email Address $contact
\n";
print "Degree: $contact
\n";
print "Address: $add
\n";
print "City: $city
\n";
print "State: $state
\n";
print "Zip: $zip
\n";
print "
\n";
print "You will receive an email when your account has been approved.\n
";
//clean up DB stuff
$conn->Close();
$rs = null;
$conn = null;
//let them know the account is waiting to be created.
mail("here@here.nmu.edu", "Account Request for $first $mi $last", "An Account Request for $user has been submitted from $first $mi $last.","From: here@here.nmu.edu\r\n");
}
}
}//end check for errors if statement
}//end program
if($rs != null){
$conn->Close();
$rs = null;
$conn = null;
}
?>