-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.php
More file actions
92 lines (74 loc) · 3.57 KB
/
Copy pathcreate.php
File metadata and controls
92 lines (74 loc) · 3.57 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
include "conexao.php";
if($_SERVER["REQUEST_METHOD"]=="POST"){
$titulo = $_POST['titulo'];
$autor = $_POST['autor'];
$anoPublicacao = $_POST['ano'];
$genero = $_POST['genero'];
$editora = $_POST['editora'];
$sql = "insert into livros(id, titulo, autor, ano, genero, editora) values
(default, '$titulo', '$autor', $anoPublicacao, '$genero', '$editora')";
$result = mysqli_query($conn, $sql);
if($result){
header("Location: index.php");
exit();
} else{
echo "Erro ao adicionar o livro.";
die("Erro ao gravar: " . mysqli_error($conn));
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel=" stylesheet"
integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous">
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js" integrity="
sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="
sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.min.js" integrity="
sha384-Rx+T1VzGupg4BHQYs2gCW9It+akI2MM/mndMCy36UVfodzcJcF0GGLxZIzObiEfa" crossorigin="anonymous"></script>
<div class="container">
<h2>Add new book</h2>
<form method="POST" action="">
<form method="POST" action="">
<div class="mb-3">
<label class="form-label" for="titulo">Título:</label>
<input class="form-control" type="text" name="titulo" maxlength="40" required><br>
</div>
<div class="mb-3">
<label class="form-label" for="titulo">Autor:</label>
<input class="form-control" type="text" name="autor" maxlength="30" required><br>
</div>
<div class="mb-3">
<label class="form-label" for="ano">Ano de Publicação:</label>
<input class="form-control" type="number" name="ano" required><br>
</div>
<div class="mb-3">
<label class="form-label" for="editora">Editora:</label>
<input class="form-control" type="text" name="editora" maxlength="30" required><br>
</div>
<label class="form-label" for="genero">Gênero:</label>
<select class="form-select" id="genero" name="genero" required>
<option value="">Selecione</option>
<option value="Programaçao">Programação</option>
<option value="Design">Design</option>
<option value="Política">Política</option>
<option value="Religião">Religião</option>
<option value="Filhos">Criação de Filhos</option>
<option value="Ficcao">Ficção Científica</option>
<option value="Outros">Outros</option>
</select><br>
<input class="btn btn-primary" type="submit" value="Adicionar Livro">
<a class="btn btn-secondary" href="index.php">Voltar</a>
</form>
</form>
</div>
</body>
</html>