-
Notifications
You must be signed in to change notification settings - Fork 0
/
inserir_pagina.php
46 lines (36 loc) · 1.13 KB
/
inserir_pagina.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
<html>
<body>
<h2>Bloco de Notas</h2>
<h4>Inserir Página</h4>
<?php
session_start();
include('functions.php');
echo("<h5>Sessão de {$_SESSION['nome']} </h5>");
$connection=createConnection();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["nome_pag"])) {
die('Nome da pagina nao preenchida');
}
$nomePag = test_input($_POST["nome_pag"]);
}
try{
$connection->beginTransaction();
$pageCounter = geraId(pagecounter, pagina, $connection);
$idSeq = geraIdSeq($connection);
$sql = "INSERT INTO pagina (userid, ppagecounter, nome, ativa, pagecounter, idseq)
VALUES (".$_SESSION['id'].", NULL, '$nomePag', 1, $pageCounter, $idSeq)";
if ($connection->query($sql) === FALSE) {
die( "Error: " . $sql . "<br>" . $conn->error);
}
$connection->commit();
} catch (Exception $e) {
$connection->rollBack();
echo "Failed: " . $e->getMessage();
}
echo("<br></br>");
echo("<p>Página inserida com sucesso</p>");
buttons();
$connection->close();
?>
</body>
</html>