-
Notifications
You must be signed in to change notification settings - Fork 0
/
editar.php
52 lines (39 loc) · 1.04 KB
/
editar.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
<h1>Editar um usuário:</h1>
<hr>
<br>
<?php
require "config.php";
require "dao/UsuarioDaoMysql.php";
$usuarioDao = new UsuarioDaoMysql($pdo);
session_start();
require "config.php";
$usuario = false;
if ($_SESSION['jaExiste']) {
echo "<h3 id='desaparece'>Usuário já existente!</h3>";
$_SESSION['jaExiste'] = false;
}
$id = filter_input(INPUT_GET, 'id');
if ($id){
$usuario = $usuarioDao -> findById($id);
}if ($usuario === false) {
header('Location: index.php');
exit;
}
?>
<form action="editarAction.php" method="POST">
<input type="hidden" name='id' value="<?php echo $usuario->getId();?>">
<label>
Nome:
<input type="text" name="name" value="<?php echo $usuario->getNome();?>">
</label><br><br>
<label>
email:
<input type="email" name='email' value="<?php echo $usuario->getEmail();?>">
</label><br><br>
<input type="submit" value='Salvar'>
</form>
<script>
setTimeout(() => {
document.getElementById('desaparece').style.display = 'none';
}, 3000)
</script>