-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathadd_bill11111.php
38 lines (26 loc) · 1.11 KB
/
add_bill11111.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
<?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
$patientid = mysqli_real_escape_string($link, $_REQUEST['patientid']);
$appointmentid = mysqli_real_escape_string($link, $_REQUEST['appointmentid']);
$billingdate = mysqli_real_escape_string($link, $_REQUEST['billingdate']);
$billingtime = mysqli_real_escape_string($link, $_REQUEST['billingtime']);
// Processing form data when form is submitted
if($_SERVER["REQUEST_METHOD"] == "POST"){
// Attempt insert query execution
$sql = "INSERT INTO billing (patientid, appointmentid, billdate, billtime)
VALUES ('$patientid', '$appointmentid', '$billdate', '$billtime')";
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);
}
?>