-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f35910c
commit e6bfae0
Showing
4 changed files
with
29 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
<?php | ||
//Requisições necessárias | ||
require_once 'Conexao.php'; | ||
require_once '../html/permissao/permissao.php'; | ||
|
||
$situacao = trim($_POST["situacao"]); | ||
//Verifica se um usuário está logado e possui as permissões necessárias | ||
session_start(); | ||
permissao($_SESSION['id_pessoa'], 11, 3); | ||
|
||
//Sanitiza a entrada. | ||
$situacao = trim(filter_input(INPUT_POST, 'situacao', FILTER_SANITIZE_STRING)); | ||
|
||
if(!$situacao || empty($situacao)){ | ||
http_response_code(400); | ||
exit('Erro, a descrição de uma nova situação não pode ser vazia.'); | ||
} | ||
|
||
//Executa a consulta no banco de dados da aplicação | ||
try { | ||
$sql = "INSERT into situacao(situacoes) values(:situacao)"; | ||
$sql = "INSERT INTO situacao(situacoes) VALUES (:situacao)"; | ||
$pdo = Conexao::connect(); | ||
$stmt = $pdo->prepare($sql); | ||
$stmt->bindParam(':situacao', $situacao); | ||
$stmt->execute(); | ||
} catch (PDOException $e) { | ||
http_response_code(500); | ||
echo 'Erro ao inserir uma nova situação no banco de dados: '.$e->getMessage(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
<?php | ||
require_once'Conexao.php'; | ||
$pdo = Conexao::connect(); | ||
//Requisições necessárias | ||
require_once 'Conexao.php'; | ||
require_once '../html/permissao/permissao.php'; | ||
|
||
$sql = 'select * from situacao'; | ||
//Verifica se um usuário está logado e possui as permissões necessárias | ||
session_start(); | ||
permissao($_SESSION['id_pessoa'], 11, 3); | ||
|
||
$pdo = Conexao::connect(); | ||
|
||
try { | ||
$sql = 'SELECT * FROM situacao'; | ||
$stmt = $pdo->query($sql); | ||
$resultado = array(); | ||
while ($row = $stmt->fetch()) { | ||
$resultado[] = array('id_situacao'=>$row['id_situacao'],'situacoes'=>$row['situacoes']); | ||
$resultado[] = array('id_situacao' => $row['id_situacao'], 'situacoes' => htmlspecialchars($row['situacoes'])); | ||
} | ||
echo json_encode($resultado); | ||
?> | ||
} catch (PDOException $e) { | ||
http_response_code(500); | ||
echo $e->getMessage(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters