-
Notifications
You must be signed in to change notification settings - Fork 10
/
new_prescription.php
39 lines (27 loc) · 1.3 KB
/
new_prescription.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
<?php
$link = mysqli_connect("localhost", "root", "", "clinic_db");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Define variables and initialize with empty values
// Escape user inputs for security
$doctorid = mysqli_real_escape_string($link, $_REQUEST['doctorid']);
$patientid = mysqli_real_escape_string($link, $_REQUEST['patientid']);
$prescriptiondate = mysqli_real_escape_string($link, $_REQUEST['prescriptiondate']);
$status = mysqli_real_escape_string($link, $_REQUEST['status']);
$appointmentid = mysqli_real_escape_string($link, $_REQUEST['appointmentid']);
// Processing form data when form is submitted
if($_SERVER["REQUEST_METHOD"] == "POST"){
// Attempt insert query execution
$sql = "INSERT INTO prescription (doctorid, patientid, delivery_type, delivery_id, prescriptiondate, status, appointmentid)
VALUES ('$doctorid', '$patientid', 'Delivered through appointment', '$appointmentid', '$prescriptiondate', 'Active', '$appointmentid')";
if(mysqli_query($link, $sql)){
header("location: patientreport.php?patientid=$patientid&appointmentid=$appointmentid");
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
}
?>