-
Notifications
You must be signed in to change notification settings - Fork 0
/
criarconsulta.php
41 lines (34 loc) · 1.1 KB
/
criarconsulta.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
<?php
//conectando ao db
include("connection.php");
//verificando se o usuario esta logado
if((!isset ($_SESSION['login'])) && !($_SESSION['nivel']==1))
{
session_destroy();
header('location:logincadastro.php'); exit;
}
//definindo variaveis locais
$data = $_POST['data'];
$hora = $_POST['horario'];
$medico = $_POST['medselect'];
$logado = $_SESSION['login'];
//recuperando o nome do usuario
$sql = "SELECT primeiroNome FROM cadastros WHERE name = ?";
$stmt = $con->prepare($sql);
$stmt-> bind_param("s", $logado);
$stmt->execute() or die("Erro!");
$stmt->bind_result($name) or die("Erro!");
while ($stmt->fetch()) {
$primeironome = $name;
}
//inserindo nova consulta
$stat = "pendente";
$query = "INSERT INTO consultas(medico,nome,data,horario,status) VALUES (?,?,?,?,?)";
$stmt = $con->prepare($query) or die("Erro!");
$stmt->bind_param("sssss",$medico,$primeironome,$data,$hora,$stat) or die("Erro!");
$stmt->execute() or die("Erro ao executar!");
$stmt->close();
$con->close();
header("location:indexCadastro.php");
//****************************************** TESTADO OK *****************************
?>