-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
62 lines (55 loc) · 1.6 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
<?php
include_once 'core/init.php';
setHeader();
setNav();
$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(
'name' => array(
'required'=>true,
'min' =>2,
'max'=>50
)
));
if ($validation->passed()) {
// update profile
try {
$user->update(array(
'name'=>Input::get('name')
));
Session::flash('home','Details Updated Successfully !');//flash alert to users
Redirect::to('index.php');
} catch (Exception $e) {
die($e->getMessage());
}
}else{?>
<div class="alert alert-warning" style="width:35%; margin-left: 30%;margin-top: 2%; text-align: center;color: red;">
<?php
foreach ($validation ->errors() as $error) {
echo $error , '<br>';
}?>
</div>
<?php
}
}
}
?>
<div class="panel panel-default" style="width:35%; margin-left: 30%;margin-top: 2%; text-align: center;">
<div class="panel-heading"><h6>Update Account</h6></div>
<div class="panel-body" >
<form action="" method="POST">
<div class="form-group">
<label for="name" >Update Name</label>
<input type="text" name="name" class="form-control" value="<?php echo escape($user->data()->name);?>"><br>
<input type="submit" name="submit" value="Update" class="btn btn-default">
<input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
</div>
</form>
</div>
</div>
<?php setFooter(); ?>