-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprofileAccount.php
More file actions
118 lines (97 loc) · 5.27 KB
/
profileAccount.php
File metadata and controls
118 lines (97 loc) · 5.27 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
<?php include('resources/functions/account/account.listings.list.function.php'); ?>
<!doctype html>
<html lang="en">
<head>
<?php include("resources/includes/head.inc.php"); ?>
<title>Profile | BookIt - KSU</title>
</head>
<body>
<?php include("resources/includes/header.inc.php"); ?>
<?php
include_once("resources/functions/dbconnection.function.php");
if(isset($_POST['email'])) {
$newemail = $_POST['email'];
$row = dbconnection("spSelectEmail('$newemail')");
if($row == NULL){
$message = "Email has been updated.";
dbconnection("spUpdateUser(" . $_SESSION['user']['id'] . ",'" . $newemail . "','" . $_SESSION['user']['name'] . "','" . $_SESSION['user']['password'] . "')");
$_SESSION['user']['email'] = $newemail;
}else{ $message = "The email you have entered already exist within the database please enter new one."; }
}
?>
<?php include_once("resources/includes/check.php"); ?>
<main>
<div class="container-fluid">
<div class="row">
<div class="col-lg-2 col-12 py-2 py-lg-3 pb-lg-4 bg-light" id="sidenav">
<nav class="nav nav-pills flex-column flex-sm-row flex-lg-column">
<a class="h5 mb-1 text-blue font-weight-bold flex-fill text-lg-right text-center nav-link" href="profileAccount.php">Account</a>
<a class="h5 mb-1 text-blue font-weight-bold flex-fill text-lg-right text-center nav-link" href="profileNotifications.php">Notifications</a>
<a class="h5 mb-1 text-blue font-weight-bold flex-fill text-lg-right text-center nav-link" href="profileCourses.php">Courses</a>
<a class="h5 mb-1 text-blue font-weight-bold flex-fill text-lg-right text-center nav-link" href="profileListings.php">Listings</a>
</nav>
</div>
<div class="col-12 col-lg-10 pt-4 pb-4">
<div class="mb-3">
<div class="row mb-3">
<div class="col-12">
<h4 class="font-weight-bold">Account</h4>
</div>
</div>
</div>
<form action="" method="post">
<div class="row mb-4">
<div class="col-12 col-md-4">
<div class="form-group mb-4">
<label for="email">Email</label>
<input type="text" id="email" name="email" class="form-control" value="<?php echo $_SESSION['user']['email']; ?>">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" class="form-control" value="<?php echo $_SESSION['user']['password']; ?>">
</div>
<div class="form-group">
<label for="confirm">Confirm Password</label>
<input type="password" id="confirm" name="confirm" class="form-control" value="<?php echo $_SESSION['user']['password']; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<button type="submit" class="btn btn-warning">Update</button>
</div>
</div>
</form>
<?php
if(isset($_POST['password'])){
if($_POST['password'] != $_SESSION['user']['password']){
if($_POST['password'] == $_POST['confirm']){
if(isset($_POST['password'])) {
$newpass = $_POST['password'];
dbconnection("spUpdateUser(" . $_SESSION['user']['id'] . ",'" . $_SESSION['user']['email'] . "','" . $_SESSION['user']['name'] . "','" . $newpass . "')");
}
$_SESSION['user']['password'] = $newpass;
echo '<p>Password was changed</p>';
}
else{
echo '<p>Passwords do not match re-enter please.</p>';
}
}
}
?>
<br>
<p><?php
if(isset($_POST['email']))
echo $message;
?></p>
</div>
</div>
</div>
</main>
<?php include("resources/includes/footer.inc.php"); ?>
</body>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<script src="resources/js/account.listings.js"></script>
</html>