-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation.php
More file actions
41 lines (32 loc) · 1018 Bytes
/
validation.php
File metadata and controls
41 lines (32 loc) · 1018 Bytes
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
<?php
header('Content-Type: application/json; charset=utf-8');
//conectando ao db
include ("connection.php");
//setando variaveis locais
$data = $_POST['dia'];
$horario = $_POST['hora'];
$med = $_POST['medselect'];
$login = $_POST['login'];
//recuperando o nome do usuario
$sql = "SELECT primeiroNome FROM cadastros WHERE name = ?";
$stmt = $con->prepare($sql);
$stmt-> bind_param("s", $login);
$stmt->execute() or die("Erro!");
$stmt->bind_result($name) or die("Erro!");
while ($stmt->fetch()) {
$primeironome = $name;
}
//ok agora vamos procurar no banco se ja existe uma consulta marcada nesse horario
$output = array();
$query = "SELECT * FROM consultas";
if($qryLista = $con->query($query)){
while ($row = $qryLista->fetch_assoc()) {
if(($row['data'] == $data && $row['horario'] == $horario && $row['medico'] == $med || $row['nome'] == $primeironome) && $row['status'] == 'pendente') {
$output[] = array_map('utf8_encode',$row);
break;
}
}
}
echo json_encode($output);
$con->close();
?>