Subversion Repositories cheapmusic

Rev

Rev 25 | Rev 30 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25 Rev 26
Line 23... Line 23...
23
	
23
	
24
	// Get user inputs
24
	// Get user inputs
25
	$first_name = $_POST['first_name'];
25
	$first_name = $_POST['first_name'];
26
	$last_name = $_POST['last_name'];
26
	$last_name = $_POST['last_name'];
27
	$email = $_POST['email'];
27
	$email = $_POST['email'];
28
	$phone = $_POST['phone'];
28
	$zip = $_POST['zip'];
29
	$address = $_POST['address'];
-
 
30
	$password = $_POST['password'];
29
	$password = $_POST['password'];
31
	$confirm_password = $_POST['confirm_password'];
30
	$confirm_password = $_POST['confirm_password'];
32
	
31
	
33
	if(empty($first_name)){
32
	if(empty($first_name)){
34
		$valErr = 1;
33
		$valErr = 1;
Line 70... Line 69...
70
			$userData = array(
69
			$userData = array(
71
				'first_name' => $first_name,
70
				'first_name' => $first_name,
72
				'last_name' => $last_name,
71
				'last_name' => $last_name,
73
				'email' => $email,
72
				'email' => $email,
74
				'password' => password_hash($password, PASSWORD_DEFAULT),
73
				'password' => password_hash($password, PASSWORD_DEFAULT),
75
				'phone' => $phone,
74
				'zip' => $zip,
76
				'address' => $address,
-
 
77
				'activation_code' => $uniqidStr
75
				'activation_code' => $uniqidStr
78
			);
76
			);
79
			$insert = $user->insert($userData);
77
			$insert = $user->insert($userData);
80
			
78
			
81
			// Set status based on data insert
79
			// Set status based on data insert
Line 101... Line 99...
101
        $sessData['status']['msg'] = 'Please fill all mandatory fields.'; 
99
        $sessData['status']['msg'] = 'Please fill all mandatory fields.'; 
102
    }
100
    }
103
 
101
 
104
	// Store signup status into the session
102
	// Store signup status into the session
105
    $_SESSION['sessData'] = $sessData;
103
    $_SESSION['sessData'] = $sessData;
106
    $redirectURL = ($sessData['status']['type'] == 'success')?'index.php':'registration.php';
104
    $redirectURL = ($sessData['status']['type'] == 'success')?'login.php':'registration.php';
107
	
105
	
108
	// Redirect to the home/login page
106
	// Redirect to the home/login page
109
    header("Location:".$redirectURL);
107
    header("Location:".$redirectURL);
110
	exit;
108
	exit;
111
}elseif(isset($_POST['loginSubmit'])){
109
}elseif(isset($_POST['loginSubmit'])){
Line 150... Line 148...
150
	
148
	
151
	// Store login status into the session
149
	// Store login status into the session
152
    $_SESSION['sessData'] = $sessData;
150
    $_SESSION['sessData'] = $sessData;
153
	
151
	
154
	// Redirect to the home page
152
	// Redirect to the home page
155
    header("Location:index.php");
153
    header("Location:login.php");
156
	exit;
154
	exit;
157
}elseif(isset($_POST['forgotSubmit'])){
155
}elseif(isset($_POST['forgotSubmit'])){
158
	$frmDisplay = '';
156
	$frmDisplay = '';
159
	
157
	
160
	// Get user inputs
158
	// Get user inputs
Line 253... Line 251...
253
        $sessData['status']['msg'] = 'All fields are mandatory, please fill all the fields.'; 
251
        $sessData['status']['msg'] = 'All fields are mandatory, please fill all the fields.'; 
254
    }
252
    }
255
	
253
	
256
	// Store reset password status into the session
254
	// Store reset password status into the session
257
    $_SESSION['sessData'] = $sessData;
255
    $_SESSION['sessData'] = $sessData;
258
    $redirectURL = ($sessData['status']['type'] == 'success')?'index.php':'resetPassword.php?fp_code='.$fp_code;
256
    $redirectURL = ($sessData['status']['type'] == 'success')?'login.php':'resetPassword.php?fp_code='.$fp_code;
259
	
257
	
260
	// Redirect to the login/reset pasword page
258
	// Redirect to the login/reset pasword page
261
    header("Location:".$redirectURL);
259
    header("Location:".$redirectURL);
262
	exit;
260
	exit;
263
}elseif(isset($_REQUEST['verifyEmail']) && $_REQUEST['verifyEmail'] == 1){
261
}elseif(isset($_REQUEST['verifyEmail']) && $_REQUEST['verifyEmail'] == 1){
Line 288... Line 286...
288
		$sessData['status']['msg'] = 'You have used the wrong verification link, please check your email inbox and try again.';
286
		$sessData['status']['msg'] = 'You have used the wrong verification link, please check your email inbox and try again.';
289
	}
287
	}
290
	
288
	
291
	// Store account activation status into the session
289
	// Store account activation status into the session
292
    $_SESSION['sessData'] = $sessData;
290
    $_SESSION['sessData'] = $sessData;
293
    $redirectURL = 'index.php';
291
    $redirectURL = 'login.php';
294
	
292
	
295
	//Redirect to the login page
293
	//Redirect to the login page
296
    header("Location:".$redirectURL);
294
    header("Location:".$redirectURL);
297
	exit;
295
	exit;
298
}elseif(isset($_POST['updateProfile']) && !empty($_SESSION['sessData']['userID'])){
296
}elseif(isset($_POST['updateProfile']) && !empty($_SESSION['sessData']['userID'])){
Line 303... Line 301...
303
	
301
	
304
	// Get user inputs
302
	// Get user inputs
305
	$first_name = $_POST['first_name'];
303
	$first_name = $_POST['first_name'];
306
	$last_name = $_POST['last_name'];
304
	$last_name = $_POST['last_name'];
307
	$email = $_POST['email'];
305
	$email = $_POST['email'];
308
	$phone = $_POST['phone'];
306
	$zip = $_POST['zip'];
309
	$address = $_POST['address'];
-
 
310
	
307
	
311
	if(empty($first_name)){
308
	if(empty($first_name)){
312
		$valErr = 1;
309
		$valErr = 1;
313
		$sessData['field_error']['first_name'] = 'Please enter your first name.';
310
		$sessData['field_error']['first_name'] = 'Please enter your first name.';
314
	}
311
	}
Line 342... Line 339...
342
			// Prepare user data 
339
			// Prepare user data 
343
			$userData = array(
340
			$userData = array(
344
				'first_name' => $first_name,
341
				'first_name' => $first_name,
345
				'last_name' => $last_name,
342
				'last_name' => $last_name,
346
				'email' => $email,
343
				'email' => $email,
347
				'phone' => $phone,
344
				'zip' => $zip
348
				'address' => $address
-
 
349
			);
345
			);
350
			
346
			
351
			// Profile picture upload
347
			// Profile picture upload
352
			$fileErr = 0;
348
			$fileErr = 0;
353
			if(isset($_FILES['picture']['name']) && $_FILES['picture']['name'] != ""){
349
			if(isset($_FILES['picture']['name']) && $_FILES['picture']['name'] != ""){
Line 378... Line 374...
378
				$update = $user->update($userData, $conditions);
374
				$update = $user->update($userData, $conditions);
379
				
375
				
380
				// Set status based on data insert
376
				// Set status based on data insert
381
				if($update){
377
				if($update){
382
					$sessData['status']['type'] = 'success';
378
					$sessData['status']['type'] = 'success';
383
					$sessData['status']['msg'] = 'Your profile information has been updated successfully.';
379
					$sessData['status']['msg'] = 'Your profile information has been updated.';
384
				}else{
380
				}else{
385
					$sessData['status']['type'] = 'error';
381
					$sessData['status']['type'] = 'error';
386
					$sessData['status']['msg'] = 'Some problem occurred, please try again.';
382
					$sessData['status']['msg'] = 'Some problem occurred, please try again.';
387
				}
383
				}
388
			}
384
			}
Line 392... Line 388...
392
        $sessData['status']['msg'] = 'Please fill all mandatory fields.'; 
388
        $sessData['status']['msg'] = 'Please fill all mandatory fields.'; 
393
    }
389
    }
394
	
390
	
395
	// Store signup status into the session
391
	// Store signup status into the session
396
    $_SESSION['sessData'] = $sessData;
392
    $_SESSION['sessData'] = $sessData;
397
	$redirectURL = 'edit-account.php';
393
	$redirectURL = 'editAccount.php';
398
	
394
	
399
	//redirect to the profile page
395
	//redirect to the profile page
400
    header("Location:".$redirectURL);
396
    header("Location:".$redirectURL);
401
	exit;
397
	exit;
402
}elseif(isset($_POST['updatePassword']) && !empty($_SESSION['sessData']['userID'])){
398
}elseif(isset($_POST['updatePassword']) && !empty($_SESSION['sessData']['userID'])){
Line 445... Line 441...
445
        $sessData['status']['msg'] = 'Please fill all mandatory fields.'; 
441
        $sessData['status']['msg'] = 'Please fill all mandatory fields.'; 
446
    }
442
    }
447
	
443
	
448
	// Store reset password status into the session
444
	// Store reset password status into the session
449
    $_SESSION['sessData'] = $sessData;
445
    $_SESSION['sessData'] = $sessData;
450
    $redirectURL = 'settings.php';
446
    $redirectURL = 'changePassword.php';
451
	
447
	
452
	// Redirect to the pasword settings page
448
	// Redirect to the pasword settings page
453
    header("Location:".$redirectURL);
449
    header("Location:".$redirectURL);
454
	exit;
450
	exit;
455
}elseif(!empty($_REQUEST['logoutSubmit'])){
451
}elseif(!empty($_REQUEST['logoutSubmit'])){
Line 478... Line 474...
478
    $sessData['status']['type'] = 'success';
474
    $sessData['status']['type'] = 'success';
479
    $sessData['status']['msg'] = 'You have logged off your account.';
475
    $sessData['status']['msg'] = 'You have logged off your account.';
480
    $_SESSION['sessData'] = $sessData;
476
    $_SESSION['sessData'] = $sessData;
481
	
477
	
482
	// Redirect to the home page
478
	// Redirect to the home page
483
    header("Location:index.php");
479
    header("Location:login.php");
484
	exit;
480
	exit;
485
}else{
481
}else{
486
	// Redirect to the home page
482
	// Redirect to the home page
487
    header("Location:index.php");
483
    header("Location:login.php");
488
	exit;
484
	exit;
489
}
485
}