-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_account.php
63 lines (60 loc) · 2.23 KB
/
edit_account.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
<?php
$page_title = 'Editar cuenta';
require_once('includes/load.php');
page_require_level(3);
?>
<?php
//update user other info
if(isset($_POST['update'])){
$req_fields = array('name','username' );
validate_fields($req_fields);
if(empty($errors)){
$id = (int)$_SESSION['user_id'];
$name = remove_junk($db->escape($_POST['name']));
$username = remove_junk($db->escape($_POST['username']));
$sql = "UPDATE users SET name ='{$name}', username ='{$username}' WHERE id='{$id}'";
$result = $db->query($sql);
if($result && $db->affected_rows() === 1){
$session->msg('s',"Cuenta actualizada. ");
redirect('edit_account.php', false);
} else {
$session->msg('d','Modificación fallida');
redirect('edit_account.php', false);
}
}else{
$session->msg("d", $errors);
redirect('edit_account.php',false);
}
}
?>
<?php include_once('layouts/header.php'); ?>
<div class="row">
<div class="col-md-12">
<?php echo display_msg($msg); ?>
</div>
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading clearfix">
<span class="glyphicon glyphicon-edit"></span>
<span>Editar mi cuenta</span>
</div>
<div class="panel-body">
<form method="post" action="edit_account.php?id=<?php echo (int)$user['id'];?>" class="clearfix">
<div class="form-group">
<label for="name" class="control-label">Nombres</label>
<input type="name" class="form-control" name="name" value="<?php echo remove_junk(ucwords($user['name'])); ?>">
</div>
<div class="form-group">
<label for="username" class="control-label">Usuario</label>
<input type="text" class="form-control" name="username" value="<?php echo remove_junk(ucwords($user['username'])); ?>">
</div>
<div class="form-group clearfix">
<a href="change_password.php" title="change password" class="btn btn-danger pull-right">Cambiar contraseña</a>
<button type="submit" name="update" class="btn btn-success">Actualizar</button>
</div>
</form>
</div>
</div>
</div>
</div>
<?php include_once('layouts/footer.php'); ?>