-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathappointmentEx.php
More file actions
80 lines (57 loc) · 2.1 KB
/
Copy pathappointmentEx.php
File metadata and controls
80 lines (57 loc) · 2.1 KB
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
72
73
74
75
76
77
78
79
80
<?php
session_start();
include "db_conn.php";
$service = "";
$dataID = "";
if(isset($_POST['service'])){
$selectedServices = $_POST['service'];
$service = implode(", ", $selectedServices);
}
$date = date('M-d-Y', strtotime('now'));
$dateID = $_POST['dateID'];
$fName = $_POST['fName'];
$lName = $_POST['lName'];
$mName = $_POST['mName'];
$name = $fName . " " . $mName . " " . $lName;
$dateTime = $_POST['dateTime'];
$position = $_POST['position'];
if (empty($fName)) {
echo '<script type="text/javascript">';
echo 'alert("First name is empty!");';
echo 'window.history.back();';
echo '</script>';
} else if (empty($lName)) {
echo '<script type="text/javascript">';
echo 'alert("Last name is empty!");';
echo 'window.history.back();';
echo '</script>';
} else if (empty($mName)) {
echo '<script type="text/javascript">';
echo 'alert("Middle name is empty!");';
echo 'window.history.back();';
echo '</script>';
} else if (empty($dateTime)) {
echo '<script type="text/javascript">';
echo 'alert("Date and time is empty!");';
echo 'window.history.back();';
echo '</script>';
} else if (empty($position)) {
echo '<script type="text/javascript">';
echo 'alert("Position is empty!");';
echo 'window.history.back();';
echo '</script>';
} else {
$sql = "INSERT INTO `appointments`(`id`,`name`, `position`, `service`, `dateTime`, `date`, `state`)
VALUES ('$dateID','$name','$position','$service','$dateTime','$date','Pending')";
$result = mysqli_query($conn, $sql);
unset($_SESSION['month']);
unset($_SESSION['day']);
unset($_SESSION['year']);
unset($_SESSION['week']);
unset($_SESSION['service']);
echo '<script type="text/javascript">';
echo 'alert("Successfully created an appointment!");';
echo 'window.location.href = "appointment.php";';
echo '</script>';
}
?>