forked from MakingTrevenue/uark-mis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplicationSubmit.php
193 lines (176 loc) · 7.64 KB
/
applicationSubmit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
error_reporting(E_ALL & ~E_WARNING);
ini_set('display_errors', 1);
try {
$config = parse_ini_file('../private/credentials.ini');
$servername = $config["servername"];
$username = $config["username"];
$password = $config["password"];
$dbname = $config["dbname"];
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("INSERT INTO student (firstName, middleName, lastName, preferredName, primaryEmail, secondaryEmail, primaryPhone, secondaryPhone, socialSecurityNumber, dateOfBirth, countryOfBirth, ethnicity, gender, citizenship)
VALUES (:firstName, :middleName, :lastName, :preferredName, :primaryEmail, :secondaryEmail, :primaryPhone, :secondaryPhone, :socialSecurityNumber, :dateOfBirth, :countryOfBirth, :ethnicity, :gender, :citizenship);");
$stmt->bindParam(':firstName', $firstName);
$stmt->bindParam(':middleName', $middleName);
$stmt->bindParam(':lastName', $lastName);
$stmt->bindParam(':preferredName', $preferredName);
$stmt->bindParam(':primaryEmail', $primaryEmail);
$stmt->bindParam(':secondaryEmail', $secondaryEmail);
$stmt->bindParam(':primaryPhone', $primaryPhone);
$stmt->bindParam(':secondaryPhone', $secondaryPhone);
$stmt->bindParam(':socialSecurityNumber', $socialSecurityNumber);
$stmt->bindParam(':dateOfBirth', $dateOfBirth);
$stmt->bindParam(':ethnicity', $ethnicity);
$stmt->bindParam(':gender', $gender);
$stmt->bindParam(':citizenship', $citizenship);
$stmt->bindParam(':countryOfBirth', $countryOfBirth);
$firstName = $_POST['firstName'];
$middleName = $_POST['middleName'];
$lastName = $_POST['lastName'];
$preferredName = $_POST['preferredName'];
$primaryEmail = $_POST['primaryEmail'];
$secondaryEmail = $_POST['secondaryEmail'];
$primaryPhone = $_POST['primaryPhone'];
$secondaryPhone = $_POST['secondaryPhone'];
$socialSecurityNumber = $_POST['socialSecurityNumber'];
$dateOfBirth = $_POST['dateOfBirth'];
$ethnicity = $_POST['ethnicity'];
$gender = $_POST['gender'];
$citizenship = $_POST['citizenship'];
$countryOfBirth = 'US';
$stmt->execute();
echo "Student record created successfully";
$stmt = $conn->prepare("INSERT INTO application (studentID, term, year, program, reqScholarship, previousApp, previousAppDate, previousEnrollment, previousEnrollmentDate, previousEnrollmentStatus, undergradGPA, juniorseniorGPA,
currentEmployer, timeAtCurrentEmployer, gmat, gmatTestDate,gmatQScore, gmatVScore, gmatTScore, gre, greTestDate, greQScore, greVScore, greTScore, toeflOnline, toeflPaper, toeflTestDate, toeflOnlineScore,
toeflPaperScore, tse, tseTestDate, tseScore)
VALUES (LAST_INSERT_ID(), :term, :year, :program, :reqScholarship, :previousApp, :previousAppDate, :previousEnrollment, :previousEnrollmentDate, :previousEnrollmentStatus, :undergradGPA, :juniorseniorGPA,
:currentEmployer, :timeAtCurrentEmployer, :gmat, :gmatTestDate, :gmatQScore, :gmatVScore, :gmatTScore, :gre, :greTestDate, :greQScore, :greVScore, :greTScore, :toeflOnline, :toeflPaper, :toeflTestDate, :toeflOnlineScore,
:toeflPaperScore, :tse, :tseTestDate, :tseScore )");
$stmt->bindParam(':term', $term);
$stmt->bindParam(':year', $year);
$stmt->bindParam(':program', $program);
$stmt->bindParam(':reqScholarship', $reqScholarship);
$stmt->bindParam(':previousApp', $previousApp);
$stmt->bindParam(':previousAppDate', $previousAppDate);
$stmt->bindParam(':previousEnrollment', $previousEnrollment);
$stmt->bindParam(':previousEnrollmentDate', $previousEnrollmentDate);
$stmt->bindParam(':previousEnrollmentStatus', $previousEnrollmentStatus);
$stmt->bindParam(':undergradGPA', $undergradGPA);
$stmt->bindParam(':juniorseniorGPA', $juniorseniorGPA);
$stmt->bindParam(':currentEmployer', $currentEmployer);
$stmt->bindParam(':timeAtCurrentEmployer', $timeAtCurrentEmployer);
$stmt->bindParam(':gmat', $gmat);
$stmt->bindParam(':gmatTestDate', $gmatTestDate);
$stmt->bindParam(':gmatQScore', $gmatQScore);
$stmt->bindParam(':gmatVScore', $gmatVScore);
$stmt->bindParam(':gmatTScore', $gmatTScore);
$stmt->bindParam(':gre', $gre);
$stmt->bindParam(':greTestDate', $greTestDate);
$stmt->bindParam(':greQScore', $greQScore);
$stmt->bindParam(':greVScore', $greVScore);
$stmt->bindParam(':greTScore', $greTScore);
$stmt->bindParam(':toeflOnline', $toeflOnline);
$stmt->bindParam(':toeflPaper', $toeflPaper);
$stmt->bindParam(':toeflTestDate', $toeflTestDate);
$stmt->bindParam(':toeflOnlineScore', $toeflOnlineScore);
$stmt->bindParam(':toeflPaperScore', $toeflPaperScore);
$stmt->bindParam(':tse', $tse);
$stmt->bindParam(':tseTestDate', $tseTestDate);
$stmt->bindParam(':tseScore', $tseScore );
$term= $_POST['term'];
$year= $_POST['year'];
$program = $_POST['program'];
if(isset($_POST['reqScholarship']))
$reqScholarship = $_POST['reqScholarship'];
else
$reqScholarship = 0;
if(isset($_POST['previousApp']))
$previousApp = $_POST['previousApp'];
else
$previoiusApp = 0;
$previousAppDate = $_POST['previousAppDate'];
if(isset($_POST['previousEnrollment']))
$previousEnrollment = $_POST['previousEnrollment'];
else
$previousEnrollment=0;
$previousEnrollmentDate = $_POST['previousEnrollmentDate'];
$previousEnrollmentStatus = $_POST['previousEnrollmentStatus'];
$undergradGPA = $_POST['undergradGPA'];
$juniorseniorGPA = $_POST['juniorseniorGPA'];
$currentEmployer = $_POST['currentEmployer'];
$timeAtCurrentEmployer = $_POST['timeAtCurrentEmployer'];
if(isset($_POST['gmat']))
$gmat = $_POST['gmat'];
else
$gmat=0;
$gmatTestDate = $_POST['gmatTestDate'];
$gmatQScore = $_POST['gmatQScore'];
$gmatVScore = $_POST['gmatVScore'];
$gmatTScore = $_POST['gmatTScore'];
if(isset($_POST['gre']))
$gre = $_POST['gre'];
else
$gre=0;
$greTestDate = $_POST['greTestDate'];
$greQScore = $_POST['greQScore'];
$greVScore = $_POST['greVScore'];
$greTScore = $_POST['greTScore'];
if(isset($_POST['toeflOnline']))
$toeflOnline = $_POST['toeflOnline'];
else
$toeflOnline = 0;
if(isset($_POST['toeflPaper']))
$toeflPaper = $_POST['toeflPaper'];
else
$toeflPaper = 0;
$toeflTestDate = $_POST['toeflTestDate'];
$toeflOnlineScore = $_POST['toeflOnlineScore'];
$toeflPaperScore = $_POST['toeflPaperScore'];
if(isset($_POST['tse']))
$tse = $_POST['tse'];
else
$tse=0;
$tseTestDate = $_POST['tseTestDate'];
$tseScore = $_POST['tseScore'];
$stmt->execute();
echo "<br>";
echo "Application record created successfully";
$appid = $conn->lastInsertId();
$fileFormName=array('resumeFile','essayQuestionsFile','transcriptFile','recLetter1','recLetter2','recLetter3');
try{
foreach($fileFormName as $fn){
if(isset($_FILES[$fn])){
$file_name=$_FILES[$fn]['name'];
$file_size=$_FILES[$fn]['size'];
$file_tmp=$_FILES[$fn]['tmp_name'];
$file_type=$_FILES[$fn]['type'];
$fn=md5_file($_FILES[$fn]['tmp_name']);
if(strlen($fn)<5)
continue;
move_uploaded_file($file_tmp,"../docs/".$fn);
$stmt = $conn->prepare("INSERT INTO attachment (applicationID,documentType,filename)
VALUES (:appID,:docType,:filename);");
$stmt->bindParam(':appID', $applicationID);
$stmt->bindParam(':docType', $docType);
$stmt->bindParam(':filename', $filename);
$docType= $file_type;
$filename = $fn;
$applicationID=$appid;
$stmt->execute();
echo "<br>";
echo "Attachment record created successfully";
}else{
}
}
}catch(Exception $e){
echo "<br>Error: " . $e->getMessage();
echo "<br> Stack trace: " . $e->getTraceAsString();
}
}
catch(Exception $e){
echo "Error: " . $e->getMessage();
echo "<br> Stack trace: " . $e->getTraceAsString();
}
$conn = null;
?>