-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.php
86 lines (39 loc) · 1.65 KB
/
process.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
// make sure there is connection to php page ----> action = "process.php" method = "post"//
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "Cafedb";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
if(isset($_POST['submit'])) {
if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['phone']) && !empty($_POST['date']) && !empty($_POST['department']) && !empty($_POST['doctor']) && !empty($_POST['message'])) {
$fullname = $_POST['name'];
$email = $_POST['email'];
$phonenumber = $_POST['phone'];
$Date = $_POST['date'];
$department = $_POST['department'];
$doctor = $_POST['doctor'];
$Message = $_POST['message'];
//var_dump($fullname,$email,$phonenumber);
//Insert Data to database
// Users ----> The name of the table.
// Fullnames, email, phonenumber ----> Name of the columns.
$query = "insert into patients(name, email, phone, Appointmentdate, department, doctor, message) values('$fullname' , '$email', '$phonenumber', ' $Date', ' $department' ,'$doctor','$Message')";
//run query
$run = mysqli_query($conn, $query) or die('Error: ' . mysqli_error($conn));;
//check if our query runs
if ($run) {
echo '<alert>Information Submitted successfully!</alert> ';
header("Location:index.php");
}
else {
echo 'Data not submitted';
}
}
else {
echo 'All fields are required';
}
}
// Always make sure that the date in the database has the null property.
?>