forked from Bkoech/gbvis
-
Notifications
You must be signed in to change notification settings - Fork 1
/
editprofile.php
executable file
·140 lines (102 loc) · 4.54 KB
/
editprofile.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
<?php
$page_title = "Reset Password | GBV";
$current_page = "Reset password";
require_once 'includes/global.inc.php';
//check to see if they're logged in
if(!isset($_SESSION['logged_in'])) {
header("Location: login.php");
}
//get the user object from the session
$user = unserialize($_SESSION['user']);
//initialize php variables used in the form
$firstname = $user->firstname;
$lastname = $user->lastname;
$username = $user->username;
$current_password = $user->hashedPassword;
$email = $user->email;
$sector = $user->sector;
$user_group = $user->user_group;
$mobile_phone = $user->mobile_phone;
$message = "";
$groups_result = $db->selectData("user_groups","id = $user_group");
foreach ($groups_result as $grows)
{
$user_group = $grows['id'];
$group_name = $grows['group_name'];
}
$sectors_result = $db->selectData("sectors","sector_id = $sector");
foreach ($sectors_result as $srows)
{
$sector = $srows['sector_id'];
$sector_name = $srows['sector'];
}
//check to see that the form has been submitted
if(isset($_POST['submit-settings'])) {
//retrieve the $_POST variables
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$mobile_phone = $_POST['mobile_phone'];
$email = $_POST['email'];
$new_password = $_POST['password'];
$user->firstname= $firstname;
$user->lastname = $lastname;
$user->email = $email;
$user->mobile_phone = $mobile_phone;
$user->hashedPassword = ($new_password==$current_password) ? $current_password : md5($new_password) ;
$user->save();
$message = "Profile Updated successfully";
}
//If the form wasn't submitted, or didn't validate
//then we show the registration form again
include "includes/Dash_header.php"; //TA:60:1
include "includes/topbar.php"; //TA:60:1
?>
<script type="text/javascript">
</script>
<div id="sidebar">
<div class="sidebar-nav">
<?php
include "includes/sidebar.php";
?>
</div>
</div>
<div id="main-content_with_side_bar">
<div id="content-body">
<h3 class="page-title">Edit Profile</h3>
<div class="profile-data" align="left">
<div><p style="font-family:Verdana, Geneva, sans-serif; font-size:12px; color:red;padding-left:25px"><?php echo $message; ?></p></div>
<?php if($message === ""){ ?>
<form action="" method="post" >
<div class="labelsDiv">First name:</div>
<div class="inputsDiv"> <input type="text" value="<?php echo $firstname; ?>" name="firstname" class="textInputs" /></div><br clear="all">
<div class="labelsDiv">Last Name:</div>
<div class="inputsDiv"> <input type="text" value="<?php echo $lastname; ?>" name="lastname" class="textInputs" /></div><br clear="all">
<div class="labelsDiv">Username: </div>
<div class="inputsDiv"><input type="text" value="<?php echo $username; ?>" name="username" readonly class="textInputs" /></div><br clear="all">
<div class="labelsDiv">E-Mail:</div>
<div class="inputsDiv"> <input type="text" value="<?php echo $email; ?>" name="email" class="textInputs" /></div><br clear="all">
<div class="labelsDiv">User Group: </div>
<div class="inputsDiv"><input type="text" value="<?php echo $group_name; ?>" readonly name="user_group" class="textInputs" /></div><br clear="all">
<div class="labelsDiv">Sector: </div>
<div class="inputsDiv"><input type="text" value="<?php echo $sector_name; ?>" readonly name="sector" class="textInputs"/></div><br clear="all">
<div class="labelsDiv">Mobile phone: </div>
<div class="inputsDiv"><input type="text" value="<?php echo $mobile_phone; ?>" name="mobile_phone" class="textInputs"/></div><br clear="all">
<div class="labelsDiv">Password: </div>
<div class="inputsDiv"><input type="password" value="<?php echo $current_password; ?>" name="password" class="textInputs"/></div><br clear="all">
<br clear="all">
<div class="labelsDiv"></div>
<div class="inputsDiv"><input type="submit" value="Update" name="submit-settings" class="login_button" /></div>
<br clear="all">
<br clear="all">
</form>
<?php } ?>
<br clear="all">
<br clear="all">
</div><br clear="all">
<br clear="all">
</center>
</div><br clear="all">
</div>
<?php
include "includes/footer.php";
?>