-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.php
More file actions
70 lines (50 loc) · 1.71 KB
/
settings.php
File metadata and controls
70 lines (50 loc) · 1.71 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
<?php require_once("includes/views/header.php") ?>
<?php if (!$session->is_signed_in()) {redirect("login.php");} ?>
<?php
// The forms where signed in user can change their information.
// Should be placed in a popup of some kind or another page.
// Currently only here to place the users form they use to update their infomration.
if (empty($_GET['id'])) {
$user = User::find_by_id($session->user_id);
} elseif (User::is_admin($session->user_id) && isset($_GET['id'])) {
$user = User::find_by_id($_GET['id']);
} else {
redirect("users.php");
}
if (isset($_POST['submit'])) {
$first_name = trim($_POST['first_name']);
$middle_name = trim($_POST['middle_name']);
$last_name = trim($_POST['last_name']);
// Verify_update lies in User and check what is sent in, more parameters to be added.
$error_array = User::verify_update($first_name, $middle_name, $last_name);
if (empty($error_array)) {
$user->first_name = $first_name;
$user->middle_name = $middle_name;
$user->last_name = $last_name;
// Updates the user-row in the database.
$user->update();
echo "Updated!";
} else {
echo "Not updated!";
}
}
?>
<div>
<form id="login-id" action="" method="post">
<div class="">
<label>First Name</label>
<input type="text" name="first_name" value="<?php echo $user->first_name ?>" >
</div>
<div class="">
<label>Middle Name</label>
<input type="text" name="middle_name" value="<?php echo $user->middle_name; ?>" >
</div>
<div class="">
<label>Last Name</label>
<input type="text" name="last_name" value="<?php echo $user->last_name; ?>" >
</div>
<div class="">
<input type="submit" name="submit" value="Submit">
</div>
</form>
</div>