-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform-edit.php
73 lines (68 loc) · 2.47 KB
/
form-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
71
72
73
<?php
include_once './init.php';
// pega o ID da URL
$id = isset($_GET['isbn']) ? (int) $_GET['isbn'] : null;
// valida o ID
if (empty($id)) {
echo "ID para alteração não definido";
exit;
}
// busca os dados do usuário a ser editado
$PDO = db_connect();
$sql = "SELECT isbn,titulo,autor,sobrenome,editora,preco FROM livros WHERE id = :id";
$stmt = $PDO->prepare($sql);
$stmt->bindParam(':isbn', $id, PDO::PARAM_INT);
$stmt->execute();
$livro = $stmt->fetch(PDO::FETCH_ASSOC);
// se o método fetch() não retornar um array, significa que o ID não corresponde
// a um usuário válido
if (!is_array($livro)) {
echo "Nenhum Livro Encontrado";
exit;
}
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- add materialize-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link rel="stylesheet" href="materialize/css/custon.css">
<title>Power Livros</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col s1 ">
</div>
<div class="col s10">
<div class="card-panel black blue-text text-darken-2">
<h2>Cadastrar Livros</h2>
<h4>Edição de Livros</h4>
</div>
<form action="edit.php" method="post">
<label>ISBN:</label>
<input type="text" name="isbn" placeholder="Digite o ISBN do livro"><br /><br />
<label>Titulo:</label>
<input type="text" name="titulo" placeholder="Digite o título"><br />
<label>Autor:</label>
<input type="text" name="autor" placeholder="Digite o nome do autor"><br /><br />
<label>Genero:</label>
<input type="text" name="gereno" placeholder="Digite o genero do livro "><br /><br />
<label>Editora:</label>
<input type="text" name="editora" placeholder="Digite a editora">
<label>Preço:</label>
<input type="text" name="preco" placeholder="Digite o Preço"><br /><br />
<input type="submit" value="Alterar">
</form>
</div>
<div class="col s1 ">
</div>
</div>
</div>
</body>
</html>