-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathregistrationForm.php
More file actions
466 lines (403 loc) · 13.8 KB
/
Copy pathregistrationForm.php
File metadata and controls
466 lines (403 loc) · 13.8 KB
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
<?php
require_once'core/init.php';
if(Input::exists()){
if(Token::check(Input::get('token'))){
$displayerror = '';
$validate = new Validate();
$validation = $validate->check($_POST,array(
//1st Particulars
'ID' => array(
'required' => true,
'numbered' => true,
'unique' => 'users',
'max' => 10,
'min' => 10
),
'Course' => array(),
'school' => array(),
'Room_ID' => array(),
//2nd Particulars
'Name' => array(
'required' => true,
),
'Password' => array(
'required' => true,
'min' =>6
),
'reenterPassword' => array(
'required' => true,
'matches' => 'Password'
),
'house_no' => array(
'required' => true,
),
'area' => array(
'required' => true,
),
'postcode' => array(
'required' => true,
'max' => 5,
),
'State' => array(
'required' => true
),
'IC' => array(
'required' => true,
'numbered' => true
),
'gender' => array(
'required' => true
),
'race' => array(
'required' => true
),
'religion' => array(
'required' => true
),
'EMail' => array(
'required' => true,
'email form' => true
),
'telephone' => array(
'required' => true,
'numbered' => true
),
//3rd Particulars
'GName' => array(
'required' => true,
),
'GRelationship' => array(
'required' => true,
),
'GTelephoneNo' => array(
'required' => true,
'numbered' => true,
),
'GEMail' => array(
'required' => true,
'email form' => true,
),
'GHouse_No' => array(
'required' => true,
),
'GArea' => array(
'required' => true,
),
'GPostcode' => array(
'required' => true,
'max' => 5,
),
));
if($validation->passed()){
$user = new User();
$salt = Hash::salt(32);
if(Input::get('Room_ID')){
$room = new Room();
$room_info = $room->get_room(Input::get('Room_ID'));
if($room_info->room_cap < $room_info->room_occupied){
$room->add_tenant($room_info->room_id);
}
if($room_info->room_cap == $room_info->room_occupied){
$room->mark_full($room_info->room_id);
}
}
try{
$user->create(array(
'Name' => Input::get('Name'),
'ID' => Input::get('ID'),
'Password' => Hash::make(Input::get('Password'),$salt),
'salt' => $salt,
'IC' => Input::get('IC'),
'Course' => Input::get('Course'),
'School' => Input::get('school'),
'TelephoneNo' => Input::get('telephone'),
'Email' => Input::get('EMail'),
'Gender' => Input::get('gender'),
'Race' => Input::get('race'),
'Religion' => Input::get('religion'),
'House_No' => Input::get('house_no'),
'Area' => Input::get('area'),
'Postcode' => Input::get('postcode'),
'State' => Input::get('State'),
'RegDateTime' => datetime(),
'RoomID' => Input::get('Room_ID'),
'GroupNo' => 4,
'GName' => Input::get('GName'),
'GRelationship' => Input::get('GRelationship'),
'GEMail' => Input::get('GEMail'),
'GHouse_No' => Input::get('GHouse_No'),
'GArea' => Input::get('GArea'),
'GPostcode' => Input::get('GPostcode'),
'GTelephoneNo' => Input::get('GTelephoneNo')
));
Session::flash('home','Registration successful, Please login');
Redirect::to('login.php');
}catch(Exception $e){
die($e->getMessage());
}
}else{
foreach($validation->errors() as $error){
$displayerror.= $error.'<br>';
}
Session::flash('error',$displayerror);
}
}
}
?>
<!DOCTYPE html>
<html lang="en" manifest="MMC.appcache">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hostel Registration Form</title>
<link rel="stylesheet" type="text/css" href="css/registrationForm.css">
</head>
<body>
<!-- container -->
<div id="container">
<!-- header -->
<div id="header">
<img src="image/project header.jpg" width="1024" height="100" />
</div>
<!-- end of header -->
<div id="errorBox">
<?php
echo '<p>' .Session::flash('error').'</p>';
?>
</div>
</div>
<!-- form content -->
<div id="formContent">
<form action method="post" enctype="multipart/form-data">
<!-- 1st particular -->
<div id="firstParticular">
<table width="100%" border="0">
<tr>
<td align="center" bgcolor="#0066FF"> <font size="+1"> <b> 1. Academic Particulars </b> </font> </td>
</tr>
</table>
<table width="80%" align="center" border="0">
<tr>
<div class="field">
<td><label for="ID">Student ID Number</label></td>
<td align="center"> : </td>
<td> <input name="ID" type="text" size="55" maxlength="20" value="<?php echo escape(Input::get('ID')); ?>" /> </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="course">Course</label></td>
<td align="center"> : </td>
<td> <select name="Course">
<option> Please select your course </option>
<option value="DTE"> Diploma In Technology ( Telecommunication Engineering ) </option>
<option value="DNM"> Diploma In Creative New Media </option>
<option value="DSE"> Diploma In Software Engineering </option>
<option value="DMT"> Diploma In Information Technology </option>
<option value="DMG"> Diploma In Management with Multimedia </option>
<option value="DIA"> Diploma In Accounting </option>
</select> </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="school">School</label></td>
<td align="center"> : </td>
<td> <select name="school">
<option> Please select your school </option>
<option value="Engineering"> School of Engineering </option>
<option value="IT & Multimedia"> School of IT and Multimedia </option>
<option value="Business & Accounting"> School of Business and Accounting </option>
</select>
</td>
</div>
</tr>
<tr>
<td>Room ID</td>
<td> : </td>
<td><select name="Room_ID">
<!-- Add php script to list empty rooms -->
<?php
$block_list = new Block();
$block_list->get_vacant_room_registration_form()
?>
</select>
</td>
</tr>
</table>
</div>
<!-- end of 1st particular -->
<!-- 2nd particular -->
<div id="secondParticular">
<table width="100%" border="0">
<tr>
<td align="center" bgcolor="#0066FF"> <font size="+1"> <b> 2. Personal Particulars </b> </font> </td>
</tr>
</table>
<table width="80%" align="center" border="0">
<tr>
<div class="field">
<td><label for="Name">Name</label></td>
<td align="center"> : </td>
<td> <input name="Name" type="text" size="55" maxlength="100" value="<?php echo escape(Input::get('Name')); ?>" /> </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="Password">Password</label></td>
<td align="center"> : </td>
<td> <input name="Password" type="password" size="55" maxlength="15" /> </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="reenterPassword">Re-enter Password</label></td>
<td align="center"> : </td>
<td><input name="reenterPassword" type="password" size="55" maxlength="15" /> </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="address">Home Address</label><br><br><br><br></td>
<td align="center">:<br><br><br><br></td>
<td align="left">
<input type="text" name="house_no" size="55"><br>
<input type="text" name="area" size="55"><br>
<input type="text" name="postcode" size="55"><br>
</td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="State">State</label></td>
<td align="center"> : </td>
<td> <select name="State">
<option> Please select your state </option>
<option value="Johor"> Johor Darul Takzim </option>
<option value="Kedah"> Kedah Darul Aman </option>
<option value="Kelantan"> Kelantan Darul Naim </option>
<option value="Melaka"> Melaka Bandaraya Bersejarah </option>
<option value="Negeri Sembilan"> Negeri Sembilan Darul Khusus </option>
<option value="Pahang"> Pahang Darul Makmur </option>
<option value="Perak"> Perak Darul Ridzuan </option>
<option value="Perlis"> Perlis Indera Kayangan </option>
<option value="Pulau Pinang"> Pulau Pinang Pulau Mutiara </option>
<option value="Sabah"> Sabah Negeri Di Bawah Bayu </option>
<option value="Sarawak"> Sarawak Bumi Kenyalang </option>
<option value="Selangor"> Selangor Darul Ehsan </option>
<option value="Terengganu"> Terengganu Darul Iman </option>
<option value="Kuala Lumpur"> Wilayah Persekutuan Kuala Lumpur </option>
<option value="Labuan"> Wilayah Persekutuan Labuan </option>
<option value="Putrajaya"> Wilayah Persekutuan Putrajaya </option>
</select> </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="IC">Mykad Number</label></td>
<td align="center"> : </td>
<td> <input name="IC" type="text" size="55" maxlength="14" value="<?php echo escape(Input::get('IC')); ?>" /> </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="gender">Gender</label></td>
<td align="center"> : </td>
<td> <input type="radio" name="gender" value="M"> Male
<input type="radio" name="gender" value="F"> Female </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="race">Race</label></td>
<td align="center"> : </td>
<td> <input type="radio" name="race" value="malay"> Malay
<input type="radio" name="race" value="chinese"> Chinese
<input type="radio" name="race" value="indian"> Indian
<input type="radio" name="race" value="others"> Others </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="religion">Religion</label></td>
<td align="center"> : </td>
<td> <input type="radio" name="religion" value="islam"> Islam
<input type="radio" name="religion" value="christian"> Christian
<input type="radio" name="religion" value="buddha"> Buddha
<input type="radio" name="religion" value="others"> Others </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="EMail">E-mail Address</label></td>
<td align="center"> : </td>
<td> <input name="EMail" type="text" size="55" maxlength="40" value="<?php echo escape(Input::get('EMail')); ?>" /> </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="telephone">Telephone Number</label></td>
<td align="center"> : </td>
<td> <input name="telephone" type="text" size="55" maxlength="20" value="<?php echo escape(Input::get('telephone')); ?>" /></td>
</div>
</tr>
</table>
</div>
<!-- end of 2nd particular -->
<!-- 3rd particular -->
<div id="thirdParticular">
<table width="100%" border="0">
<tr>
<td align="center" bgcolor="#0066FF"> <font size="+1"> <b> 3. Person To Be Notified In Case Of Emergency / Guarantor </b> </font> </td>
</tr>
</table>
<table width="80%" align="center" border="0">
<tr>
<div class="field">
<td><label for="GName">Name</label></td>
<td align="center"> : </td>
<td> <input name="GName" type="text" size="55" maxlength="50" /> </td>
</tr>
<tr>
<div class="field">
<td><div style="margin-bottom:10px"><label for="GAdress">Home Address</label><br><br><br><br></div> </td>
<td align="center"> :<br><br><br><br></td>
<td align="left">
<input type="text" name="GHouse_No" size="55"><br>
<input type="text" name="GArea" size="55"><br>
<input type="text" name="GPostcode" size="55"><br>
</td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="GRelationship">Relationship</label></td>
<td align="center"> : </td>
<td> <input name="GRelationship" type="text" size="55" maxlength="15" /> </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="GTelephoneNo">Telephone Number</label></td>
<td align="center"> : </td>
<td> <input name="GTelephoneNo" type="text" size="55" maxlength="15" /> </td>
</div>
</tr>
<tr>
<div class="field">
<td><label for="GEMail">Guarantor Email</label></td>
<td align="center"> : </td>
<td> <input name="GEMail" type="text" size="55" maxlength="50" /> </td>
</div>
</tr>
</table>
<input type="hidden" name='token' value="<?php echo Token::generate();?>">
<p align="right"><input name="submit" type="submit" value="Submit" /></p>
</div>
<!-- end of 3rd particular -->
</form>
</div>
<!-- end of form content -->
</div>
<!-- end of container -->
</body>
</html>