-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_profile.php
79 lines (64 loc) · 1.97 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
<?php require_once("includes/initialize.php"); ?>
<?php
if(!$session->is_logged_in()) {
redirect_to("login.php");
}
if(isset($session->user_id)) {
$id = $session->user_id;
$user = User::find_by_id($session->user_id);
} else {
$session->user_id = "";
}
if(isset($_POST['submit'])) {
$password = sha1($_POST['password']);
$repeated_password = sha1($_POST['repeated_password']);
$array = array("id" => $id, "password" => $password);
if($password == $repeated_password && (!empty($repeated_password))) {
if(User::update($array)) {
$session->message("Password successfully changed.");
redirect_to("profile.php");
}
}
} else {
$password = NULL;
}
?>
<?php require_once($uredivanje_profila = "includes/header.php"); ?>
<div class="cAlign">
<div id="fullWidthSection">
<h4><?php echo output_message($message); ?></h4>
<form action="edit_profile.php" class="contact_form" method="post">
<ul>
<li>
<h2>Edit profile</h2>
</li>
<li>
<label for="name">Name:</label>
<input type="text" name="name" id="name" readonly="readonly" value="<?php echo User::full_name_for_current_user(); ?>">
</li>
<li>
<label for="password">New password:</label>
<input type="password" name="password" required>
</li>
<li>
<label for="repeated_password">Repeat new password:</label>
<input type="password" name="repeated_password" required>
</li>
<li>
<label for="mail">E-mail:</label>
<input type="mail" name="mail" readonly="readonly" value="<?php echo $user['mail']; ?>">
</li>
<li>
<label for="date">Registration date:</label>
<input type="text" name="date" readonly="readonly" value="<?php echo datetime_to_text($user['date']); ?>">
</li>
<li>
<button type="submit" name="submit" class="submit">Update profile</button>
</li>
</ul>
</form>
<h4><a href="edit_profile.php">Back</a></h4>
</div>
<div class="cBoth"></div>
</div>
<?php require_once("includes/footer.php"); ?>