-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.php
executable file
·72 lines (58 loc) · 1.57 KB
/
update.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
<?php
require_once 'core/init.php';
$pagename = "Update";
include_once 'includes/head.php';
include_once 'includes/header.php';
$user = new User();
if (!$user->isLoggedIn()) {
Redirect::to('index.php');
}
if(Input::exists()) {
if(Token::check((Input::get('token')))){
$validate = new Validate();
$validation = $validate->check($_POST, array(
'firstname' => array (
'required' => true,
'min' => 2,
'max' => 50
),
'lastname' => array (
'required' => true,
'min' => 2,
'max' => 50
)
));
if($validation->passed()){
try {
$user->update(array(
'firstname' => Input::get('firstname'),
'lastname' => Input::get('lastname')
));
Session::flash('home', $LANG['updatecompl']);
Redirect::to('index.php');
} catch(Exception $e){
die($e->getMessage());
}
} else {
foreach ($validation->errors() as $error) {
echo $error, '<br>';
}
}
}
}
?>
<form action="" method="POST">
<div class="field">
<label for="firstname"><?php echo $LANG['firstname']; ?></label>
<input type="text" name="firstname" value="<?php echo escape($user->data()->firstname); ?>">
</div>
<div class="field">
<label for="lastname">Lastname</label>
<input type="text" name="lastname" value="<?php echo escape($user->data()->lastname); ?>">
<input type="submit" value="<?php echo $LANG['update_button']; ?>">
<input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
</div>
</form>
<?php
include_once 'includes/bottom.php';
?>