-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsalvar-cadastrar.php
57 lines (44 loc) · 1.78 KB
/
salvar-cadastrar.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
<?php
switch($_REQUEST["acao"]){
case "autor":
$nome_autor = $_REQUEST["nome_autor"];
$telefone = $_REQUEST["telefone"];
$email = $_REQUEST["email"];
$sql = "INSERT INTO autor (nome_autor, telefone, email) VALUES ('$nome_autor','$telefone', '$email')";
$result = $conn->query($sql);
if($result){
print "<script>alert('Cadastrou com sucesso!');</script>";
print "<script>location.href='index.php?page=cadastrar-autor';</script>";
}else{
print "<div class='alert alert-danger'>Houve um problema.</div>";
}
break;
case "categoria":
$categoria = $_REQUEST["categoria"];
$sql = "INSERT INTO categoria (categoria) VALUES ('$categoria')";
$result = $conn->query($sql);
if($result){
print "<script>alert('Cadastrou com sucesso!');</script>";
print "<script>location.href='index.php?page=cadastrar-categoria';</script>";
}else{
print "<div class='alert alert-danger'>Houve um problema.</div>";
}
break;
case "livro":
$autor = $_REQUEST["autor_id_autor"];
$categoria = $_REQUEST["categoria_id_categoria"];
$quantidade = $_REQUEST["quantidade"];
$local_entrega = $_REQUEST["local_entrega"];
$data_entrega = $_REQUEST["data_entrega"];
$especificacao = $_REQUEST["especificacao"];
$sql = "INSERT INTO livros (autor_id_autor, categoria_id_categoria, quantidade, local_entrega, data_entrega, especificacao) VALUES ($autor, $categoria, '$quantidade', '$local_entrega', '$data_entrega', '$especificacao')";
$result = $conn->query($sql);
if($result){
print "<script>alert('Cadastrou com sucesso!');</script>";
print "<script>location.href='index.php?page=cadastrar-livros';</script>";
}else{
print "<div class='alert alert-danger'>Houve um problema.</div>";
}
break;
}
?>