Corporate Processing registration

Request NOT Submitted

Please go back to the form, fill out all the required fields, and re-submit.

‘;
die();
}

$first_name = addslashes($_POST[‘f_name’]);
$middle_name = addslashes($_POST[‘m_name’]);
$last_name = addslashes($_POST[‘l_name’]);
$student_id = addslashes($_POST[‘student_id’]);

$email = addslashes($_POST[’email’]);
$dob_day = addslashes($_POST[‘dob_day’]);
$dob_month = addslashes($_POST[‘dob_month’]);
$dob_year = addslashes($_POST[‘dob_year’]);
$phone1 = addslashes($_POST[‘phone1’]);
$texting =addslashes($_POST[‘texting’]);
$c_name = addslashes($_POST[‘c_name’]);
$already_admitted = addslashes($_POST[‘already_admitted’]);
$prog_name = addslashes($_POST[‘prog_name’]);

$comments = addslashes($_POST[‘comments’]);
$ipaddress = $_SERVER[‘REMOTE_ADDR’];

$RegType = ‘sem’;

//first course
$firstcourse = explode(‘+’,$_POST[‘course1’]);
$crn1 = $firstcourse[3]; //for entry into CourseReg table

//Second course
$secondcourse = explode(‘+’,$_POST[‘course2’]);
$crn2 = 0; //use to check how many courses
$crn2 = $secondcourse[3]; //for entry into CourseReg table

//third course
$thirdcourse = explode(‘+’,$_POST[‘course3’]);
$crn3 = 0; //use to check how many courses
$crn3 = $thirdcourse[3]; //for entry into CourseReg table

//fourth course
$fourcourse = explode(‘+’,$_POST[‘course4’]);
$crn4 = 0; //use to check how many courses
$crn4 = $fourcourse[3]; //for entry into CourseReg table

//fifth course
$fifthcourse = explode(‘+’,$_POST[‘course5’]);
$crn5 = 0; //use to check how many courses
$crn5 = $fifthcourse[3]; //for entry into CourseReg table

//sixth course
$sixthcourse = explode(‘+’,$_POST[‘course6’]);
$crn6 = 0; //use to check how many courses
$crn6 = $sixthcourse[3]; //for entry into CourseReg table

//insert class values into database and set up part of email

if ($crn1 <> 0) {
$sql = “INSERT INTO CourseReg (crn, student_id, TimeStamp) VALUES (‘$crn1’, ‘$student_id’, current_TIMESTAMP())”;
$result = @mysql_query($sql,$connection) or die(mysql_error());
$courses .= ”
CRN: {$firstcourse[3]}
DEPT: {$firstcourse[0]} – NUM: {$firstcourse[1]} – SEC: {$firstcourse[2]} – CREDITS: {$firstcourse[6]}
TITLE: {$firstcourse[4]}
INSTRUCTOR: {$firstcourse[5]}\n\n”;
}

if ($crn2 <> 0) {
$sql = “INSERT INTO CourseReg (crn, student_id, TimeStamp) VALUES (‘$crn2’, ‘$student_id’, current_TIMESTAMP())”;
$result = @mysql_query($sql,$connection) or die(mysql_error());
$courses .= ”
CRN: {$secondcourse[3]}
DEPT: {$secondcourse[0]} – NUM: {$secondcourse[1]} – SEC: {$secondcourse[2]} – CREDITS: {$secondcourse[6]}
TITLE: {$secondcourse[4]}
INSTRUCTOR: {$secondcourse[5]}\n\n”;
}

if ($crn3 <> 0) {
$sql = “INSERT INTO CourseReg (crn, student_id, TimeStamp) VALUES (‘$crn3’, ‘$student_id’, current_TIMESTAMP())”;
$result = @mysql_query($sql,$connection) or die(mysql_error());
$courses .= “CRN: {$thirdcourse[3]}
DEPT: {$thirdcourse[0]} – NUM: {$thirdcourse[1]} – SEC: {$thirdcourse[2]} – CREDITS: {$thirdcourse[6]}
TITLE: {$thirdcourse[4]}
INSTRUCTOR: {$thirdcourse[5]}\n\n”;
}
if ($crn4 <> 0) {
$sql = “INSERT INTO CourseReg (crn, student_id, TimeStamp) VALUES (‘$crn4’, ‘$student_id’, current_TIMESTAMP())”;
$result = @mysql_query($sql,$connection) or die(mysql_error());
$courses .= “CRN: {$fourcourse[3]}
DEPT: {$fourcourse[0]} – NUM: {$fourcourse[1]} – SEC: {$fourcourse[2]} – CREDITS: {$fourcourse[6]}
TITLE: {$fourcourse[4]}
INSTRUCTOR: {$fourcourse[5]}\n\n”;
}
if ($crn5 <> 0) {
$sql = “INSERT INTO CourseReg (crn, student_id, TimeStamp) VALUES (‘$crn5’, ‘$student_id’, current_TIMESTAMP())”;
$result = @mysql_query($sql,$connection) or die(mysql_error());
$courses .= “CRN: {$fifthcourse[3]}
DEPT: {$fifthcourse[0]} – NUM: {$fifthcourse[1]} – SEC: {$fifthcourse[2]} – CREDITS: {$fifthcourse[6]}
TITLE: {$fifthcourse[4]}
INSTRUCTOR: {$fifthcourse[5]}\n\n”;
}
if ($crn6 <> 0) {
$sql = “INSERT INTO CourseReg (crn, student_id, TimeStamp) VALUES (‘$crn6’, ‘$student_id’, current_TIMESTAMP())”;
$result = @mysql_query($sql,$connection) or die(mysql_error());
$courses .= “CRN: {$sixthcourse[3]}
DEPT: {$sixthcourse[0]} – NUM: {$sixthcourse[1]} – SEC: {$sixthcourse[2]} – CREDITS: {$sixthcourse[6]}
TITLE: {$sixthcourse[4]}
INSTRUCTOR: {$sixthcourse[5]}\n\n”;
}

//create message for email
$message =
“LAST NAME: {$last_name}
FIRST NAME: {$first_name}
MIDDLE NAME: {$middle_name}
STUDENT ID: {$student_id}
DATE OF BIRTH: {$dob_month} {$dob_day}, {$dob_year}
MAIN PHONE: {$phone1}
EMAIL: {$email}

COMPANY NAME: {$c_name}
HAVE YOU ALREADY BEEN ADMITTED TO A UAF DEGREE PROGRAM: {$already_admitted}
WHAT PROGRAM WERE YOU ADMITTED TO: {$prog_name}

Comments: {$comments}

IP Address: {$ipaddress}

Courses: {$courses}

\n\n”;

//email parameters
$to_email = ‘karunnion@alaska.edu’;
$from = ‘karunnion@alaska.edu’;
$title = “Registration Request Form: [$first_name] [$last_name]”;
$headers = ‘From: karunnion@alaska.edu’;

// tell gpg where to find key ring
//putenv(‘GNUPGHOME=/var/www/.gnupg’);

//create unique file name
$infile = tempnam(‘/var/www/tmp’, ‘pgp’);
$outfile = $infile.’.asc’;

//write text to the file
$fp = fopen($infile, ‘w’);
fwrite($fp, $message);
fclose($fp);

//set up the command
$command = “/usr/bin/gpg -a –homedir /var/www/.gnupg –recipient $to_email –encrypt -o $outfile $infile”;

//execute gpg command
system($command, $result);

//delete unencrypted temp file
unlink($infile);

if($result == 0) {
$fp = fopen($outfile, ‘r’);

if(!$fp||filesize ($outfile)==0) {
$result = -1;
}
else {
// read encrypted file
$contents = fread($fp, filesize($outfile));
//delete encrypted temp file
unlink($outfile);

//changed contents to message to not use encryption

//changed contents to message to not use encryption – changed to my email to test
$to_email = “uaf-ecampus-registration@alaska.edu”;
$from = “uaf-ecampus-registration@alaska.edu”;
$title = “Registration Request Form: [$first_name] [$last_name]”;
$headers = “From: uaf-ecampus-registration@alaska.edu”;
mail($to_email, $title, $message, $headers);

echo “

Thank you! We have received your course registration request with the following information:

Student Information

Name: $first_name $middle_name $last_name
Student ID or SSN: $student_id
Email: $email
Date of Birth: $dob_month $dob_day, $dob_year
Phone: $phone1
Do you accept text messages: $texting
Company name: $c_name
Have you already been admitted to a UAF degree program: $already_admitted
What program were you admitted to: $prog_name

Courses you requested to be enrolled in

$courses

Comments

$comments

“;
}
}

if ($result!=0) {
echo ‘

Error:

There was a problem with processing the form, so your registration has not been sent.

Please contact UAF eCampus at 907-455-2060 or 800-277-8060. Thank you.’;
}

?>