Subversion Repositories cheapmusic

Rev

Rev 43 | Rev 59 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
25 - 1
<?php
2
// Email sending functions
3
include_once 'includes/email_functions.php';
4
include_once 'includes/password.php';
5
 
31 - 6
// Include Session Handling
7
require_once('includes/session.php');
25 - 8
 
9
// Include config file
10
require_once 'includes/config.php';
11
 
12
// Load and initialize user class
13
require_once 'includes/User.class.php';
14
$user = new User();
15
 
16
if(isset($_POST['signupSubmit'])){
17
	$valErr = 0;
41 - 18
	$captchaErr = 0;
36 - 19
 
25 - 20
	// Store post data into session
21
	$_SESSION['signup_post_data'] = $_POST;
36 - 22
 
41 - 23
    if (!empty($_POST['g-recaptcha-response'])) {
24
        $secretKey = GR_SECRET_KEY;
25
        $ch = curl_init('https://www.google.com/recaptcha/api/siteverify?secret=' . $secretKey . '&response=' . $_POST['g-recaptcha-response']);
26
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
27
        $verifyResponse = curl_exec($ch);
28
        $responseData = json_decode($verifyResponse);
29
 
30
        if ($responseData->success){
31
            if ($responseData->score < 0.6) {
32
            	$captchaErr = 1;
33
                $sessData['status']['type'] = 'error';
34
                $sessData['status']['msg'] = 'Robot verification failed, please try again.';
35
            }
36
        } else {
37
        	$captchaErr = 1;
38
            $sessData['status']['type'] = 'error';
39
            $sessData['status']['msg'] = 'Robot verification failed, please try again.';
40
        }
41
    } else {
42
    	$captchaErr = 1;
43
        $sessData['status']['type'] = 'error';
44
        $sessData['status']['msg'] = 'Robot verification failed, please try again.';
45
    }
46
 
47
    if ($captchaErr == 1) {
48
    	// Redirect back to the registration page
49
        $_SESSION['sessData'] = $sessData;
50
        MySessionHandler::commit(session_id());
51
        header("Location:registration.php");
52
    	exit;
53
    }
54
 
25 - 55
	// Get user inputs
36 - 56
	$first_name = sanitizeInput($_POST['first_name']);
57
	$last_name = sanitizeInput($_POST['last_name']);
58
	$email = sanitizeInput($_POST['email']);
59
	$zip = sanitizeInput($_POST['zip']);
60
	$password = sanitizeInput($_POST['password']);
61
	$confirm_password = sanitizeInput($_POST['confirm_password']);
62
 
25 - 63
	if(empty($first_name)){
64
		$valErr = 1;
65
		$sessData['field_error']['first_name'] = 'Please enter your first name.';
66
	}
31 - 67
/*
25 - 68
	if(empty($last_name)){
69
		$valErr = 1;
70
		$sessData['field_error']['last_name'] = 'Please enter your last name.';
71
	}
31 - 72
*/
25 - 73
	if(empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)){
74
		$valErr = 1;
75
		$sessData['field_error']['email'] = 'Please enter a valid email.';
76
	}
77
	if(empty($password)){
78
		$valErr = 1;
79
		$sessData['field_error']['password'] = 'Please enter account password.';
80
	}
81
	if(empty($confirm_password)){
82
		$valErr = 1;
83
		$sessData['field_error']['confirm_password'] = 'Please confirm your password.';
84
	}elseif($password !== $confirm_password){
85
		$valErr = 1;
86
		$sessData['field_error']['confirm_password'] = 'Confirm password does not match the password.';
87
	}
88
 
89
	if($valErr == 0){
90
		// Check whether user exists in the database
91
		$cond['where'] = array('email' => $email);
92
		$cond['return_type'] = 'count';
93
		$userCount = $user->getRows($cond);
94
		if($userCount > 0){
95
			$sessData['status']['type'] = 'error';
96
			$sessData['status']['msg'] = 'Email already exists, please use another email.';
97
		}else{
98
			// Email verification code
99
			$uniqidStr = md5(uniqid(mt_rand()));
36 - 100
 
25 - 101
			// Insert user data in the database
102
			$userData = array(
103
				'first_name' => $first_name,
104
				'last_name' => $last_name,
105
				'email' => $email,
106
				'password' => password_hash($password, PASSWORD_DEFAULT),
26 - 107
				'zip' => $zip,
25 - 108
				'activation_code' => $uniqidStr
109
			);
110
			$insert = $user->insert($userData);
36 - 111
 
25 - 112
			// Set status based on data insert
113
			if($insert){
114
				// Remove post data from session
115
				unset($_SESSION['signup_post_data']);
36 - 116
 
25 - 117
				// Send account verification email
118
				@emailVerification($userData);
36 - 119
 
25 - 120
				$sessData['status']['type'] = 'success';
121
				$sessData['status']['msg'] = 'Your registration was successful. Please check your email inbox to verify and activate your account.';
36 - 122
 
25 - 123
				// Remove post data from session
124
				unset($_SESSION['signup_post_data']);
125
			}else{
126
				$sessData['status']['type'] = 'error';
127
				$sessData['status']['msg'] = 'Some problem occurred, please try again.';
128
			}
129
		}
130
	}else{
131
        $sessData['status']['type'] = 'error';
36 - 132
        $sessData['status']['msg'] = 'Please fill all mandatory fields.';
25 - 133
    }
134
 
135
	// Store signup status into the session
136
    $_SESSION['sessData'] = $sessData;
30 - 137
    $redirectURL = ($sessData['status']['type'] == 'success')?'index.php':'registration.php';
36 - 138
 
25 - 139
	// Redirect to the home/login page
31 - 140
    MySessionHandler::commit(session_id());
25 - 141
    header("Location:".$redirectURL);
142
	exit;
143
}elseif(isset($_POST['loginSubmit'])){
144
	// Get user inputs
36 - 145
	$email = sanitizeInput($_POST['email']);
146
	$password = sanitizeInput($_POST['password']);
147
 
25 - 148
	// Check whether login details are empty
149
    if(!empty($email) && !empty($password)){
150
		// Get user data from user class
151
        $conditions['where'] = array(
152
            'email' => $email,
153
            'status' => '1'
154
        );
155
        $conditions['return_type'] = 'single';
156
        $userData = $user->getRows($conditions);
36 - 157
 
25 - 158
		if(!empty($userData) && password_verify($password, $userData['password'])){
159
			// Set user data and status based on login credentials
160
			if($userData['activated'] == '0'){
161
				$sessData['status']['type'] = 'error';
162
				$sessData['status']['msg'] = 'Your account activation is pending, please check your email inbox to verify and activate your account.';
163
			}else{
164
				// If remember me is checked
165
				if (isset($_POST['rememberMe']) && $_POST['rememberMe'] == 1) {
31 - 166
					setcookie('rememberUserId', $userData['id'], time() + (30 * 86400), "/");
167
					setcookie('hash', password_hash($userData['password'] . $userData['id'], PASSWORD_DEFAULT), time() + (30 * 86400), "/");
25 - 168
				}
36 - 169
 
35 - 170
				$sessData['userLoggedIn'] = true;
25 - 171
				$sessData['userID'] = $userData['id'];
172
				$sessData['status']['type'] = 'success';
173
				$sessData['status']['msg'] = 'Welcome '.$userData['first_name'].'!';
174
			}
175
		}else{
176
			$sessData['status']['type'] = 'error';
36 - 177
            $sessData['status']['msg'] = 'Wrong email or password, please try again.';
25 - 178
		}
179
    }else{
180
        $sessData['status']['type'] = 'error';
36 - 181
        $sessData['status']['msg'] = 'Enter email and password.';
25 - 182
    }
36 - 183
 
25 - 184
	// Store login status into the session
185
    $_SESSION['sessData'] = $sessData;
36 - 186
 
25 - 187
	// Redirect to the home page
31 - 188
    MySessionHandler::commit(session_id());
30 - 189
    header("Location:index.php");
25 - 190
	exit;
191
}elseif(isset($_POST['forgotSubmit'])){
192
	$frmDisplay = '';
36 - 193
 
25 - 194
	// Get user inputs
36 - 195
	$email = sanitizeInput($_POST['email']);
196
 
25 - 197
	// Check whether email is empty
198
    if(!empty($email)){
199
		// Check whether user exists in the database
200
		$cond['where'] = array('email' => $email);
201
		$cond['return_type'] = 'count';
202
		$userCount = $user->getRows($cond);
203
		if($userCount > 0){
204
			// Generat unique string
205
			$uniqidStr = md5(uniqid(mt_rand()));
36 - 206
 
25 - 207
			// Update data with forgot pass code
208
			$conditions = array(
209
				'email' => $email
210
			);
211
			$data = array(
212
				'forgot_pass_identity' => $uniqidStr
213
			);
214
			$update = $user->update($data, $conditions);
36 - 215
 
25 - 216
			if($update){
217
				// Get user details
218
				$con['where'] = array('email' => $email);
219
				$con['return_type'] = 'single';
220
				$userDetails = $user->getRows($con);
36 - 221
 
25 - 222
				// Send reset password email
223
                @forgotPassEmail($userDetails);
36 - 224
 
25 - 225
				$sessData['status']['type'] = 'success';
226
				$sessData['status']['msg'] = 'Please check your email inbox, we have sent a password reset link to your registered email.';
227
				$frmDisplay = '?frmDis=0';
228
			}else{
229
				$sessData['status']['type'] = 'error';
230
				$sessData['status']['msg'] = 'Some problem occurred, please try again.';
231
			}
232
		}else{
233
			$sessData['status']['type'] = 'error';
36 - 234
			$sessData['status']['msg'] = 'Given email is not associated with any account.';
25 - 235
		}
36 - 236
 
25 - 237
    }else{
238
        $sessData['status']['type'] = 'error';
36 - 239
        $sessData['status']['msg'] = 'Enter email to create a new password for your account.';
25 - 240
    }
36 - 241
 
25 - 242
	// Store reset password status into the session
243
    $_SESSION['sessData'] = $sessData;
36 - 244
 
25 - 245
	// Redirect to the forgot pasword page
31 - 246
    MySessionHandler::commit(session_id());
25 - 247
    header("Location:forgotPassword.php".$frmDisplay);
248
}elseif(isset($_POST['resetSubmit'])){
36 - 249
	$fp_code = sanitizeInput($_POST['fp_code']);
250
 
25 - 251
	// Get user inputs
36 - 252
	$password = sanitizeInput($_POST['password']);
253
	$confirm_password = sanitizeInput($_POST['confirm_password']);
254
 
25 - 255
	if(!empty($password) && !empty($confirm_password) && !empty($fp_code)){
256
		// Password and confirm password comparison
257
        if($password !== $confirm_password){
258
            $sessData['status']['type'] = 'error';
259
            $sessData['status']['msg'] = 'Confirm password does not match the password.';
260
        }else{
261
			//check whether identity code exists in the database
262
            $cond['where'] = array('forgot_pass_identity' => $fp_code);
263
            $cond['return_type'] = 'count';
264
            $userCount = $user->getRows($cond);
265
            if($userCount > 0){
266
				// Update data with new password
267
				$conditions = array(
268
					'forgot_pass_identity' => $fp_code
269
				);
270
				$data = array(
271
					'password' => password_hash($password, PASSWORD_DEFAULT)
272
				);
273
				$update = $user->update($data, $conditions);
274
				if($update){
275
					$sessData['status']['type'] = 'success';
43 - 276
                    $sessData['status']['msg'] = 'Your account password has been reset. Please login with your new password.';
25 - 277
				}else{
278
					$sessData['status']['type'] = 'error';
279
					$sessData['status']['msg'] = 'Some problem occurred, please try again.';
280
				}
281
            }else{
282
                $sessData['status']['type'] = 'error';
283
                $sessData['status']['msg'] = 'You are not authorized to reset the password for this account.';
284
            }
285
        }
286
    }else{
287
        $sessData['status']['type'] = 'error';
36 - 288
        $sessData['status']['msg'] = 'All fields are mandatory, please fill all the fields.';
25 - 289
    }
36 - 290
 
25 - 291
	// Store reset password status into the session
292
    $_SESSION['sessData'] = $sessData;
30 - 293
    $redirectURL = ($sessData['status']['type'] == 'success')?'index.php':'resetPassword.php?fp_code='.$fp_code;
36 - 294
 
25 - 295
	// Redirect to the login/reset pasword page
31 - 296
    MySessionHandler::commit(session_id());
25 - 297
    header("Location:".$redirectURL);
298
	exit;
299
}elseif(isset($_REQUEST['verifyEmail']) && $_REQUEST['verifyEmail'] == 1){
300
	$ac_code = $_REQUEST['ac_code'];
301
 
302
	// Check whether activation code exists in the database
303
	$cond['where'] = array('activation_code' => $ac_code);
304
	$cond['return_type'] = 'count';
305
	$userCount = $user->getRows($cond);
306
	if($userCount > 0){
307
		// Update data with new password
308
		$conditions = array(
309
			'activation_code' => $ac_code
310
		);
311
		$data = array(
312
			'activated' => '1'
313
		);
314
		$update = $user->update($data, $conditions);
315
		if($update){
316
			$sessData['status']['type'] = 'success';
317
			$sessData['status']['msg'] = 'Email verification for your account was successful. Please login to your account.';
318
		}else{
319
			$sessData['status']['type'] = 'error';
320
			$sessData['status']['msg'] = 'Some problem occurred, please try again.';
321
		}
322
	}else{
323
		$sessData['status']['type'] = 'error';
324
		$sessData['status']['msg'] = 'You have used the wrong verification link, please check your email inbox and try again.';
325
	}
36 - 326
 
25 - 327
	// Store account activation status into the session
328
    $_SESSION['sessData'] = $sessData;
30 - 329
    $redirectURL = 'index.php';
36 - 330
 
31 - 331
	// Redirect to the login page
332
    MySessionHandler::commit(session_id());
25 - 333
    header("Location:".$redirectURL);
334
	exit;
335
}elseif(isset($_POST['updateProfile']) && !empty($_SESSION['sessData']['userID'])){
336
	$valErr = 0;
36 - 337
 
25 - 338
	$sessData = $_SESSION['sessData'];
36 - 339
	unset($sessData['field_error']);
340
	unset($sessData['status']);
25 - 341
	$sessUserId = $sessData['userID'];
36 - 342
 
57 - 343
//echo "<pre>", print_r($_POST, 1), "</pre>";
344
//exit;
345
 
25 - 346
	// Get user inputs
36 - 347
	$first_name = sanitizeInput($_POST['first_name']);
348
	$last_name = sanitizeInput($_POST['last_name']);
349
	$email = sanitizeInput($_POST['email']);
350
	$zip = sanitizeInput($_POST['zip']);
57 - 351
	$theme = strtolower(sanitizeInput($_POST['theme']));
352
	$conditionNew = isset($_POST['filterConditionNew']) ? 1 : 0;
353
	$conditionUsed = isset($_POST['filterConditionUsed']) ? 1 : 0;
354
	$mediaCD = isset($_POST['filterMediaTypeCD']) ? 1 : 0;
355
	$mediaRecord = isset($_POST['filterMediaTypeRecord']) ? 1 : 0;
356
	$mediaDigital = isset($_POST['filterMediaTypeDigital']) ? 1 : 0;
357
	$mediaBook = isset($_POST['filterMediaTypeBook']) ? 1 : 0;
36 - 358
 
25 - 359
	if(empty($first_name)){
360
		$valErr = 1;
361
		$sessData['field_error']['first_name'] = 'Please enter your first name.';
362
	}
31 - 363
/*
25 - 364
	if(empty($last_name)){
365
		$valErr = 1;
366
		$sessData['field_error']['last_name'] = 'Please enter your last name.';
367
	}
31 - 368
*/
25 - 369
	if(empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)){
370
		$valErr = 1;
371
		$sessData['field_error']['email'] = 'Please enter a valid email.';
372
	}
373
 
374
	if($valErr == 0){
375
		// Check whether user exists in the database
376
		$cond['where'] = array('email' => $email);
377
		$cond['where_not'] = array('id' => $sessUserId);
378
		$cond['return_type'] = 'count';
379
		$userCount = $user->getRows($cond);
380
		if($userCount > 0){
381
			$sessData['status']['type'] = 'error';
382
			$sessData['status']['msg'] = 'Email already exists, please use another email.';
383
		}else{
384
			// Get user information
385
			$conditions['where'] = array(
386
				'id' => $sessData['userID'],
387
			);
388
			$conditions['return_type'] = 'single';
389
			$userData = $user->getRows($conditions);
390
			$prevPicture = $userData['picture'];
36 - 391
 
392
			// Prepare user data
25 - 393
			$userData = array(
394
				'first_name' => $first_name,
395
				'last_name' => $last_name,
396
				'email' => $email,
57 - 397
				'zip' => $zip,
398
				'conditionNew' => $conditionNew,
399
				'conditionUsed' => $conditionUsed,
400
				'mediaCD' => $mediaCD,
401
				'mediaRecord' => $mediaRecord,
402
				'mediaDigital' => $mediaDigital,
403
				'mediaBook' => $mediaBook,
404
                                'theme' => $theme
25 - 405
			);
36 - 406
 
25 - 407
			// Profile picture upload
408
			$fileErr = 0;
36 - 409
			if(!empty($_FILES['picture']['name'])){
25 - 410
				$targetDir = UPLOAD_PATH.'profile_picture/';
36 - 411
				$fileName = time() . '_'.basename($_FILES["picture"]["tmp_name"]);
412
				$targetFilePath = $targetDir . $fileName;
413
				$fileType = strtolower(pathinfo($_FILES["picture"]["name"], PATHINFO_EXTENSION));
25 - 414
				$allowTypes = array('jpg','png','jpeg','gif');
36 - 415
				if (in_array($fileType, $allowTypes)) {
416
                    if ($_FILES["picture"]["size"] > 500000) {
417
    					$fileErr = 1;
418
	    				$sessData['status']['type'] = 'error';
419
		    			$sessData['status']['msg'] = 'Please upload a smaller image file.';
420
                    } else {
421
                        $check = getimagesize($_FILES["picture"]["tmp_name"]);
422
                        if ($check === false) {
423
        					$fileErr = 1;
424
	        				$sessData['status']['type'] = 'error';
425
		        			$sessData['status']['msg'] = 'Please upload only gif/jpg/png files.';
426
                        }
427
                    }
428
                } else {
429
	    			$fileErr = 1;
430
		    		$sessData['status']['type'] = 'error';
431
			    	$sessData['status']['msg'] = 'Please upload only gif/jpg/png files.';
432
                }
433
 
434
    			if($fileErr == 0) {
435
	    			if(move_uploaded_file($_FILES["picture"]["tmp_name"], $targetFilePath)){
436
		    			$userData['picture'] = $fileName;
437
 
438
			    		// Delete previous profile picture
439
				    	@unlink(UPLOAD_PATH.'profile_picture/'.$prevPicture);
440
        			} else {
441
                        $fileErr = 1;
442
    		    		$sessData['status']['type'] = 'error';
443
	    		    	$sessData['status']['msg'] = 'Could not upload picture.';
444
    			    	@unlink($_FILES["picture"]["tmp_name"]);
445
        			}
446
    		    } else {
447
			    	@unlink($_FILES["picture"]["tmp_name"]);
448
    			}
449
	    	}
450
 
451
   			if($fileErr == 0) {
452
       		    // Update user data in the database
453
   	    		$conditions = array(
454
   		    		'id' => $sessUserId
455
   			    );
456
 
457
   				$update = $user->update($userData, $conditions);
458
 
459
       			// Set status based on data insert
460
       			if($update){
461
   	    			$sessData['status']['type'] = 'success';
462
   		    		$sessData['status']['msg'] = 'Your profile information has been updated.';
463
   			    }else{
464
   				   	$sessData['status']['type'] = 'error';
465
   				    $sessData['status']['msg'] = 'Some problem occurred, please try again.';
466
       			}
467
            }
25 - 468
		}
469
    }else{
470
        $sessData['status']['type'] = 'error';
36 - 471
        $sessData['status']['msg'] = 'Please fill all mandatory fields.';
25 - 472
    }
36 - 473
 
25 - 474
	// Store signup status into the session
475
    $_SESSION['sessData'] = $sessData;
26 - 476
	$redirectURL = 'editAccount.php';
36 - 477
 
31 - 478
	// Redirect to the profile page
479
    MySessionHandler::commit(session_id());
25 - 480
    header("Location:".$redirectURL);
481
	exit;
482
}elseif(isset($_POST['updatePassword']) && !empty($_SESSION['sessData']['userID'])){
483
	$sessData = $_SESSION['sessData'];
36 - 484
	unset($sessData['field_error']);
485
	unset($sessData['status']);
25 - 486
	$sessUserId = $sessData['userID'];
36 - 487
 
25 - 488
	// Get user inputs
36 - 489
	$old_password = sanitizeInput($_POST['old_password']);
490
	$password = sanitizeInput($_POST['password']);
491
	$confirm_password = sanitizeInput($_POST['confirm_password']);
492
 
25 - 493
	if(!empty($password) && !empty($confirm_password)){
494
		// Password and confirm password comparison
495
        if($password !== $confirm_password){
496
            $sessData['status']['type'] = 'error';
497
            $sessData['status']['msg'] = 'Confirm password does not match the password.';
498
        }else{
499
			// Check whether identity code exists in the database
500
			$cond['where'] = array('id' => $sessUserId);
501
            $cond['return_type'] = 'single';
502
            $userData = $user->getRows($cond);
36 - 503
 
25 - 504
			if((!empty($userData) && !empty($sessData['loginType']) && $sessData['loginType'] == 'social') || (!empty($userData) && password_verify($old_password, $userData['password']))){
505
				// Update data with new password
506
				$conditions = array(
507
					'id' => $sessUserId
508
				);
31 - 509
				$passwordHash = password_hash($password, PASSWORD_DEFAULT);
25 - 510
				$data = array(
31 - 511
					'password' => $passwordHash
25 - 512
				);
513
				$update = $user->update($data, $conditions);
514
				if($update){
31 - 515
                    if (!empty($_COOKIE['rememberUserId'])){
516
    					setcookie('hash', password_hash($passwordHash . $sessUserId, PASSWORD_DEFAULT), time() + (30 * 86400), "/");
517
    				}
25 - 518
					$sessData['status']['type'] = 'success';
43 - 519
                    $sessData['status']['msg'] = 'Your account password has been updated.';
25 - 520
				}else{
521
					$sessData['status']['type'] = 'error';
522
					$sessData['status']['msg'] = 'Some problem occurred, please try again.';
523
				}
524
            }else{
525
                $sessData['status']['type'] = 'error';
526
                $sessData['status']['msg'] = 'The given old password does not match your current account password.';
527
            }
528
        }
529
    }else{
530
        $sessData['status']['type'] = 'error';
36 - 531
        $sessData['status']['msg'] = 'Please fill all mandatory fields.';
25 - 532
    }
36 - 533
 
25 - 534
	// Store reset password status into the session
535
    $_SESSION['sessData'] = $sessData;
26 - 536
    $redirectURL = 'changePassword.php';
36 - 537
 
25 - 538
	// Redirect to the pasword settings page
31 - 539
    MySessionHandler::commit(session_id());
25 - 540
    header("Location:".$redirectURL);
541
	exit;
542
}elseif(!empty($_REQUEST['logoutSubmit'])){
543
	// Include social login handler
544
	if(!empty($_SESSION['sessData']['loginType']) && ($_SESSION['sessData']['loginType'] == 'social') && !empty($_SESSION['google_access_token'])){
545
		require_once 'includes/socialLogin.php';
546
	}
36 - 547
 
25 - 548
	// Remove cookie data
31 - 549
	setcookie("rememberUserId", "", time() - 3600, "/");
550
	setcookie("hash", "", time() - 3600, "/");
551
    unset($_COOKIE['rememberUserId']);
552
    unset($_COOKIE['hash']);
36 - 553
 
25 - 554
	// Remove session data
555
	unset($_SESSION['facebook_access_token']);
556
	unset($_SESSION['FBRLH_state']);
557
	if(isset($_SESSION['google_access_token'])){
558
		// Reset OAuth access token
559
		$gClient->revokeToken();
560
	}
561
	unset($_SESSION['google_access_token']);
562
	unset($_SESSION['twitter_access_token']);
563
	unset($_SESSION['twitter_token_secret']);
564
    unset($_SESSION['sessData']);
565
    session_destroy();
36 - 566
 
31 - 567
	// Store logout status into the session
25 - 568
    $sessData['status']['type'] = 'success';
569
    $sessData['status']['msg'] = 'You have logged off your account.';
570
    $_SESSION['sessData'] = $sessData;
36 - 571
 
25 - 572
	// Redirect to the home page
31 - 573
    MySessionHandler::commit(session_id());
574
    header("Location:../index.php");
25 - 575
	exit;
576
}else{
577
	// Redirect to the home page
31 - 578
    MySessionHandler::commit(session_id());
579
    header("Location:../index.php");
25 - 580
	exit;
581
}
36 - 582
 
583
// sanitize user input
584
function sanitizeInput($data) {
585
    $data = trim(preg_replace('/[\t\n\r\s]+/', ' ', $data));
586
    $data = stripslashes($data);
587
    $data = htmlspecialchars($data);
588
    return $data;
589
}