-
Notifications
You must be signed in to change notification settings - Fork 0
/
processappointment.php
71 lines (47 loc) · 1.91 KB
/
processappointment.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
require_once('./functions/alert.php'); require_once('./functions/users.php');
session_start();
$error_count = 0;
$date = $_POST['date'] != "" ? $_POST['date'] : $error_count++;
$full_name = $_POST['full_name'] != "" ? $_POST['full_name'] : $error_count++;
$time = $_POST['time'] != "" ? $_POST['time'] : $error_count++;
$nature = $_POST['nature'] != "" ? $_POST['nature'] : $error_count++;
$complaint = $_POST['complaint'] != "" ? $_POST['complaint'] : $error_count++;
$department = $_POST['department'] != "" ? $_POST['department'] : $error_count++;
$_SESSION['date'] = $date;
$_SESSION['time'] = $time;
$_SESSION['nature'] = $nature;
$_SESSION['complaint'] = $complaint;
$_SESSION['department'] = $department;
$_SESSION['full_name'] = $full_name;
if(0 < $error_count) {
//redirect to Register page with error message
$session_error = "You have " . $error_count . " empty field";
if (1 < $error_count ) {
$session_error .= "s";
}
set_alert("error", $session_error . " in your submission. Please review");
header("Location: book_app.php ");
}
else {
$time_to_string = strtotime($time);
$formatted_time = date('h:i:sa', $time_to_string);
$all_appointment = scandir('db/appointments/');
//save appointment with unique id
$num_of_appointments = count($all_appointment);
$Id = ($num_of_appointments - 1);
$appoint_object = [
'id' => $Id,
'nature' => $nature,
'time' => $formatted_time,
'date' => $date,
'department' => $department,
'complaint' => $complaint,
"patient_name" =>$full_name
];
// print_r($apointObject);
// die();
file_put_contents("db/appointments/" . $Id . ".json", json_encode($appoint_object));
set_alert('message', "You have successfully booked an apointment to the " . $department . " department");
header("location: dashboardpatient.php");
}