-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_edit.php
executable file
·70 lines (56 loc) · 1.91 KB
/
user_edit.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
<?php
@session_start();
include('src/User.php');
$User = new User();
$id_user = $_GET['id'];
$result = $User->loadUser($id_user);
if (!empty($_POST)) {
$data = $_POST;
$id = $data['id'];
$name = $data['name'];
$email = $data['email'];
$user = $data['user'];
$pass = $data['pass'];
$User->setId($id);
$User->setUser($user);
$User->setPass($pass);
$User->setName($name);
$User->setEmail($email);
$result = $User->updateUser($id);
if (!$result['error']) {
$_SESSION['currentUser'] = $user;
$_SESSION['currentName'] = $name;
}
$_SESSION['msg'] = $result['msg'];
header("Location: ". $result['route'].$id );
exit;
}
?>
<?php include('header.php'); ?>
<div class="offset-4 col-4 offset-mobile-2 col-mobile-8">
<!-- user -->
<?php
if (!empty($_SESSION["msg"])) {
$msg = $_SESSION['msg'];
echo '<div class="alert">'.$msg.'</div>';
unset($_SESSION['msg']);
}
?>
<?php if(!empty($_GET['id']) and $_GET['id'] == $_SESSION['currentId']): ?>
<div class="form-header">Usuário</div>
<form class="user" method="POST" action="user_edit.php">
<input type="hidden" name="id" value="<?php echo $id_user; ?>">
<input class="form-pw" type="text" name="name" placeholder="Nome" value="<?php echo $result->name; ?>">
<input class="form-pw" type="text" name="user" placeholder="usuário" value="<?php echo $result->user; ?>">
<input class="form-pw" type="password" name="pass" placeholder="senha" value="<?php echo $result->pass; ?>">
<input class="form-pw" type="text" name="email" placeholder="E-mail" value="<?php echo $result->email; ?>">
<button class="btn btn-sucess" type="submit">Salvar</button>
<a href="user_delete.php?id=<?php echo $id_user; ?>" class="btn btn-danger push-right" type="submit">Remover usuário</a>
</form>
<?php else: ?>
<div class="col-12">
<div class="alert-login">Você não tem permissão para editar este usuário</div>
</div>
<?php endif; ?>
</div>
<?php include('footer.php'); ?>