This repository has been archived by the owner on Dec 7, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit_profile.php
219 lines (212 loc) · 8.75 KB
/
edit_profile.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
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
<?php
require_once 'autoload.php';
$User = new User();
$User->read(User::getSessionUserID());
if (valAllNotnull()) {
$User->setLastUpdateDate();
$iscorrect = array(
"OldPassword" => (bool) $User->isCorrectPassword($_POST["OldPassword"]),
"name" => (bool) $User->setfullName($_POST["name"]),
//"emailtaken" => (bool) $User->isEmailAvailable($_POST["email"]) || strcmp($_POST["email"], $User->getEmail()),
"email" => (bool) $User->setEmail($_POST["email"]),
"PhoneNo" => (bool) $User->setPhoneNumber($_POST["PhoneNo"]),
"Gender" => (bool) $User->setGender($_POST["Gender"]),
"Birthday" => (bool) $User->setBirthDate($_POST["BirthdayYear"], $_POST["BirthdayMonth"], $_POST["BirthdayDay"]),
"about" => (bool) $User->setAbout($_POST["about"])
);
if (Validation::valAll($iscorrect)) {
$User->update();
$Passed = true;
}
}
//=========================================validate=========================================
function valAllNotnull() {
return
isset($_POST["submit"]) &&
isset($_POST["name"]) &&
isset($_POST["email"]) &&
isset($_POST["OldPassword"]) &&
isset($_POST["BirthdayMonth"]) &&
isset($_POST["BirthdayYear"]) &&
isset($_POST["BirthdayDay"]) &&
isset($_POST["about"]) &&
isset($_POST["PhoneNo"]);
}
?><!DOCTYPE html>
<html lang="en">
<head>
<title>ACU Times | Edit Profile</title>
<?php require_once("header.php"); ?>
<script src="js/Validate.js"></script>
</head>
<body>
<?php include ("navbar.php"); ?>
<!-------------------------------------------------------------------------- content -------------------------------------------------------------------------->
<div class="container">
<h3>
<ul class="nav nav-pills">
<li role="presentation"><a href="profile.php">Profile</a></li>
<li role="presentation" class="active"><a>Change personal info</a></li>
<li role="presentation"><a href="edit_profile_pw.php">Change Password</a></li>
</ul>
</h3>
<br>
<br>
<br>
<form class="form-horizontal" role="form" action="edit_profile.php" method="post" onSubmit="return isAllValid()">
<!-- left column -->
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="text-center"> <img src="<?php echo "images/User.png"; ?>" class="img-200x200 img-circle" alt="avatar">
<div style="padding:5px"></div>
<input type="file" class="text-center center-block well well-sm btn-file">
</div>
</div>
<!-- edit form column -->
<div class="col-md-8 col-sm-6 col-xs-12 personal-info">
<?php
if (@$Passed)
echo '<div class="alert alert-info alert-dismissable"> <a class="panel-close close" data-dismiss="alert">×</a> <i class="fa fa-check"></i> Personal updated succsesfuly </div>'
?>
<h3>Personal info</h3>
<!-- #################################################################### full name #################################################################### -->
<div class="form-group">
<label class="col-md-3 control-label" for="name">Full name :</label>
<div class="controls col-md-8 ">
<input type="text"
name="name"
id="name"
value="<?php echo $User->getfullName(); ?>"
class="form-control"
onBlur="valName(this)"
required
autocomplete="on"
maxlength="32">
<span class="help-block"><ul>
<?php PrintHTML::validation("name", @$iscorrect["name"], "Enter a Valid Name (Letters and space only)") ?>
</ul></span>
</div>
</div>
<!-- #################################################################### PhoneNo #################################################################### -->
<div class="form-group">
<label class="col-md-3 control-label" for="PhoneNo">Phone Number :</label>
<div class="col-md-8 controls">
<input type="text"
name="PhoneNo"
id="PhoneNo"
value="<?php echo $User->getPhoneNumber(); ?>"
class="form-control"
maxlength="13"
onBlur="valPhoneNo(this)"
autocomplete="on">
<span class="help-block"><ul>
<?php PrintHTML::validation("PhoneNo", @$iscorrect["PhoneNo"], "Enter a correct Phone Number") ?>
</ul></span>
</div>
</div>
<!-- #################################################################### email #################################################################### -->
<div class="form-group">
<label class="col-md-3 control-label" for="email">E-Mail :</label>
<div class="col-md-8 controls">
<input type="email"
name="email"
id="email"
value="<?php echo $User->getEmail(); ?>"
class="form-control"
onBlur="valEmail(this)"
required autocomplete="on"
maxlength="256">
<span class="help-block"><ul>
<?php PrintHTML::validation("email", @$iscorrect["email"], "Enter a Valid E-mail") ?>
</ul></span>
</div>
</div>
<!-- #################################################################### Gender #################################################################### -->
<div class="form-group">
<label class="col-md-3 control-label" for="Gender">Gender :</label>
<div class="col-md-8 controls">
<select class="selectpicker form-control"
name="Gender"
id="Gender"
required>
<?php PrintHTML::OptionGender($User->getGender()) ?>
</select>
<span class="help-block"></span></div>
</div>
<!-- #################################################################### Birthday #################################################################### -->
<div class="form-group">
<label class="col-md-3 control-label" for="BirthdayYear">Birthday :</label>
<div class="col-md-8 controls" style="padding:0">
<div class="col-xs-4">
<select class="selectpicker form-control"
name="BirthdayYear"
id="BirthdayYear"
required
onBlur="valBirthday(BirthdayMonth, BirthdayYear, BirthdayDay)">
<?php
$right_now = getdate();
PrintHTML::numericOption($right_now['year'] - 16, 1900, $User->getBirthYear());
?>
</select>
</div>
<div class="col-xs-4">
<select class="selectpicker form-control" name="BirthdayMonth" id="BirthdayMonth" required onBlur="valBirthday(BirthdayMonth, BirthdayYear, BirthdayDay)">
<?php PrintHTML::numericOptionMonth($User->getBirthMonth()); ?>
</select>
</div>
<div class="col-xs-4">
<select class="selectpicker form-control"
name="BirthdayDay"
id="BirthdayDay"
required
onBlur="valBirthday(BirthdayMonth, BirthdayYear, BirthdayDay)">
<?php PrintHTML::numericOption(1, 31, $User->getBirthDay()) ?>
</select>
</div>
<span class="help-block"><ul>
<?php PrintHTML::validation("Birthday", @$iscorrect["Birthday"], "Enter a valid date") ?>
</ul></span>
</div>
</div>
<!-- #################################################################### #################################################################### -->
<div class="form-group">
<label class="col-md-3 control-label" for="about">About:</label>
<div class="col-md-8 controls">
<textarea
class="form-control"
rows="5"
id="about"
name="about"
maxlength="256"><?php echo $User->getAbout(); ?></textarea>
<span class="help-block"></span> </div>
</div>
<!-- #################################################################### #################################################################### -->
<div class="form-group">
<label class="col-md-3 control-label" for="OldPassword">Old password :</label>
<div class="col-md-8 controls">
<input type="password"
name="OldPassword"
id="OldPassword"
value=""
class="form-control"
maxlength="32"
required>
<span class="help-block"><ul>
<?php PrintHTML::validation("OldPassword", @$iscorrect["OldPassword"], "Password Don't Match") ?>
</ul></span>
</div>
</div>
<!-- #################################################################### #################################################################### -->
<div class="form-group">
<label class="col-md-3 control-label"></label>
<div class="col-md-8">
<input class="btn btn-primary" value="Save Changes" type="submit" name="submit" id="submit">
<span></span>
<input class="btn btn-default" value="Cancel" type="reset">
</div>
</div>
</div>
</form>
</div>
<?php include ("footer.php"); ?>
</body>
</html>