-
Notifications
You must be signed in to change notification settings - Fork 2
/
book.php
51 lines (43 loc) · 1.24 KB
/
book.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
<?php
require 'dbconnection.php';
$conn = OpenCon();
// read the forms request
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$age = $_POST['age'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$doc = $_POST['dr'];
$session = $_POST['type'];
$date = $_POST['date'];
$ok = true;
$messages = array();
// log patients info into patients database
$patient = "INSERT INTO `patients` (`fname`,`lname`,`age`,`email`, `phone`) VALUES ('$fname','$lname','$age','$email','$phone')";
if ($conn->query($patient) == TRUE) {
$patientId= $conn->insert_id;
}
else {
$messages[] = "An error occured while connecting to the Database";
$ok = false;
}
// if patient info has been logged then add appointment
if($ok){
$sql = "INSERT INTO `appointments` (`patientID`,`doctorName`,`service`,`datetime`) VALUES ('$patientId','$doc','$session','$date')";
if ($conn->query($sql) == TRUE) {
$ok = true;
$messages[] = "Your information has been stored! We will be in touch to confirm your booking";
}
else {
$ok = false;
$messages[] = "An error occured while connecting to the Database";
}
}
echo json_encode(
array(
'ok' => $ok,
'messages' => $messages,
)
);
CloseCon($conn);
?>