Skip to content

Instantly share code, notes, and snippets.

@vipul43
Last active April 30, 2021 11:47
Show Gist options
  • Save vipul43/7c043f957824dfb2af8236c53c857a85 to your computer and use it in GitHub Desktop.
Save vipul43/7c043f957824dfb2af8236c53c857a85 to your computer and use it in GitHub Desktop.
hospital database patient, surgery, doctor, billing, emergency patient
<html>
<body>
ID <?php echo $_POST["id"]; ?><br>
Type <?php echo $_POST["type"]; ?><br>
Patient_ID <?php echo $_POST["patient_id"]; ?><br>
Amount <?php echo $_POST["amount"]; ?><br>
Date <?php echo $_POST["date"]; ?><br>
Contact <?php echo $_POST["contact_number"]; ?><br>
<?php
$BILLINGID=$_POST["id"];
$BILLINGTYPE=$_POST["type"];
$BILLINGPATIENT_ID=$_POST["patient_id"];
$BILLINGAMOUNT=$_POST["amount"];
$BILLINGDATE=$_POST["date"];
$BILLINGCONTACT=$_POST["contact_number"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "billing";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "INSERT INTO billing (id, type, patient_id, amount, date, contact_number) VALUES ('$BILLINGID', '$BILLINGTYPE', '$BILLINGPATIENT_ID', '$BILLINGAMOUNT', '$BILLINGDATE', '$BILLINGCONTACT')";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully added<br>";
echo "$BILLINGID<br>";
echo "$BILLINGTYPE<br>";
echo "$BILLINGPATIENT_ID<br>";
echo "$BILLINGAMOUNT<br>";
echo "$BILLINGDATE<br>";
echo "$BILLINGCONTACT<br>";
echo '<form method="post" action="billing.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO ADD DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<html>
<body>
<body style="background-color:#383A59; color:white">
<?php
$DOCTORID=$_POST["id"];
$DOCTORNAME=$_POST["name"];
$DOCTOREXPERIENCE=$_POST["experience"];
$DOCTORDESIGNATION=$_POST["designation"];
$DOCTORDATEJOINED=$_POST["date_joined"];
$DOCTORCONTACTNUMBER=$_POST["contact_number"];
$DOCTORWORKINGHOURS=$_POST["working_hours"];
$DOCTORSALARY=$_POST["salary"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "doctor";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "INSERT INTO doctor (id, name, experience, designation, date_joined,contact_number,working_hours,salary) VALUES ('$DOCTORID', '$DOCTORNAME', '$DOCTOREXPERIENCE', '$DOCTORDESIGNATION', '$DOCTORDATEJOINED','$DOCTORCONTACTNUMBER','$DOCTORWORKINGHOURS','$DOCTORSALARY')";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully added<br>";
echo "$DOCTORID<br>";
echo "$DOCTORNAME<br>";
echo "$DOCTOREXPERIENCE<br>";
echo "$DOCTORDESIGNATION<br>";
echo "$DOCTORDATEJOINED<br>";
echo "$DOCTORCONTACTNUMBER<br>";
echo "$DOCTORWORKINGHOURS<br>";
echo "$DOCTORSALARY<br>";
echo '<form method="post" action="doctor.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO ADD DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<html>
<body>
<?php
echo '<body style="background-color:#383A59; color:white">';
$PATIENTID=$_POST["id"];
$PATIENTNAME=$_POST["name"];
$PATIENTADDRESS=$_POST["address"];
$PATIENTCONTACT=$_POST["contact_number"];
$PATIENTGENDER=$_POST["gender"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "emergency_patient";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "INSERT INTO emergency_patient (id, name, address, contact_number, gender) VALUES ('$PATIENTID', '$PATIENTNAME', '$PATIENTADDRESS', '$PATIENTCONTACT', '$PATIENTGENDER')";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully added<br>";
echo "$PATIENTID<br>";
echo "$PATIENTNAME<br>";
echo "$PATIENTADDRESS<br>";
echo "$PATIENTCONTACT<br>";
echo "$PATIENTGENDER<br>";
echo '<form method="post" action="epatient.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO ADD DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<html>
<body>
<?php
echo '<body style="background-color:#383A59; color:white">';
$PATIENTID=$_POST["id"];
$PATIENTNAME=$_POST["name"];
$PATIENTADDRESS=$_POST["address"];
$PATIENTCONTACT=$_POST["contact_number"];
$PATIENTGENDER=$_POST["gender"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "patient";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "INSERT INTO patient (id, name, address, contact_number, gender) VALUES ('$PATIENTID', '$PATIENTNAME', '$PATIENTADDRESS', '$PATIENTCONTACT', '$PATIENTGENDER')";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully added<br>";
echo "$PATIENTID<br>";
echo "$PATIENTNAME<br>";
echo "$PATIENTADDRESS<br>";
echo "$PATIENTCONTACT<br>";
echo "$PATIENTGENDER<br>";
echo '<form method="post" action="patient.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO ADD DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<html>
<body>
<?php
echo '<body style="background-color:#383A59; color:white">';
$SURGERYID=$_POST["id"];
$PATIENTID=$_POST["patient_id"];
$PATIENTNAME=$_POST["patient_name"];
$TIMEOFSURGERY=$_POST["time_of_surgery"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "patient";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "INSERT INTO surgery (id, patient_id, patient_name, time_of_surgery) VALUES ('$SURGERYID', '$PATIENTID', '$PATIENTNAME', '$TIMEOFSURGERY')";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully added<br>";
echo "$SURGERYID<br>";
echo "$PATIENTID<br>";
echo "$PATIENTNAME<br>";
echo "$TIMEOFSURGERY<br>";
echo '<form method="post" action="surgery.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO ADD DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>Hospital</h1>
<form method="post">
<input type="submit" name="addBilling"
class="button" value="add billing" />
<input type="submit" name="editBilling"
class="button" value="edit billing" />
<input type="submit" name="deleteBilling"
class="button" value="delete billing" />
<input type="submit" name="showBilling"
class="button" value="show billing" />
</form>
<?php
echo '<body style="background-color:#383A59; color:white">';
if(array_key_exists('addBilling', $_POST)) {
addBilling();
}
else if(array_key_exists('editBilling', $_POST)) {
editBilling();
}
else if(array_key_exists('deleteBilling', $_POST)) {
deleteBilling();
}
else if(array_key_exists('showBilling', $_POST)) {
showBilling();
}
function addBilling() {
echo '<form method="post" action="add_billing.php">
ID: <input type="text" name="id"><br>
Type: <input type="text" name="type"><br>
Patient_ID: <input type="text" name="patient_id"><br>
Amount: <input type="text" name="amount"><br>
Date: <input type="text" name="date"><br>
Contact: <input type="text" name="contact_number"><br>
<input type="submit">
</form>';
}
function editBilling() {
echo '<form method="post" action="edit_billing.php">
ID: <input type="text" name="id"><br>
Type: <input type="text" name="type"><br>
Patient_ID: <input type="text" name="patient_id"><br>
Amount: <input type="text" name="amount"><br>
Date: <input type="text" name="date"><br>
Contact: <input type="text" name="contact_number"><br>
<input type="submit">
</form>';
}
function deleteBilling() {
echo '<form method="post" action="delete_billing.php">
BILLING ID: <input type="text" name="id"><br>
<input type="submit" value="commit">
</form>';
}
function showBilling() {
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "billing";
$mysqli = new mysqli("localhost", $username, $password, $database);
echo "<h2>BILLING</h2><ol>";
$query = "SELECT * FROM billing";
$result = $mysqli->query($query);
echo '<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td> <font face="Monospace">ID</font> </td>
<td> <font face="Monospace">Type</font> </td>
<td> <font face="Monospace">Patient_ID</font> </td>
<td> <font face="Monospace">Amount</font> </td>
<td> <font face="Monospace">Date</font> </td>
<td> <font face="Monospace">Contact Number</font> </td>
</tr>';
while ($row = $result->fetch_assoc()) {
$field1name = $row["id"];
$field2name = $row["type"];
$field3name = $row["patient_id"];
$field4name = $row["amount"];
$field5name = $row["date"];
$field6name = $row["contact_number"];
echo '<tr>
<td> <font face="Monospace">'.$field1name.'</td>
<td> <font face="Monospace">'.$field2name.'</td>
<td> <font face="Monospace">'.$field3name.'</td>
<td> <font face="Monospace">'.$field4name.'</td>
<td> <font face="Monospace">'.$field5name.'</td>
<td> <font face="Monospace">'.$field6name.'</td>
</tr>';
}
$result->free();
echo "</ol>";
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
}
?>
</body>
</html>
<html>
<body>
<?php
echo '<body style="background-color:#383A59; color:white">';
$BILLINGID=$_POST["id"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "billing";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "DELETE FROM billing where id = '$BILLINGID'";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully deleted<br>";
echo "$BILLINGID<br>";
echo "$BILLINGTYPE<br>";
echo "$BILLINGPATIENT_ID<br>";
echo "$BILLINGAMOUNT<br>";
echo "$BILLINGDATE<br>";
echo "$BILLINGCONTACT<br>";
echo '<form method="post" action="billing.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO DELETE DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<html>
<body>
<?php
echo '<body style="background-color:#383A59; color:white">';
$DOCTORID=$_POST["id"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "doctor";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "delete from doctor where id = '$DOCTORID'";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully deleted<br>";
echo "$DOCTORID<br>";
echo "$DOCTORNAME<br>";
echo "$DOCTOREXPERIENCE<br>";
echo "$DOCTORDESIGNATION<br>";
echo "$DOCTORDATEJOINED<br>";
echo "$DOCTORCONTACTNUMBER<br>";
echo "$DOCTORWORKINGHOURS<br>";
echo "$DOCTORSALARY<br>";
echo '<form method="post" action="doctor.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO UPDATE DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<html>
<body>
<?php
echo '<body style="background-color:#383A59; color:white">';
$PATIENTID=$_POST["id"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "emergency_patient";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "delete from emergency_patient where id = '$PATIENTID'";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully deleted<br>";
echo "$PATIENTID<br>";
echo '<form method="post" action="epatient.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO UPDATE DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<html>
<body>
<?php
echo '<body style="background-color:#383A59; color:white">';
$PATIENTID=$_POST["id"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "patient";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "delete from patient where id = '$PATIENTID'";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully deleted<br>";
echo "$PATIENTID<br>";
echo '<form method="post" action="patient.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO UPDATE DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<html>
<body>
<?php
echo '<body style="background-color:#383A59; color:white">';
$SURGERYID=$_POST["id"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "surgery";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "delete from surgery where id = '$SURGERYID'";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully deleted<br>";
echo "$SURGERYID<br>";
echo '<form method="post" action="surgery.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO UPDATE DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>Hospital</h1>
<form method="post">
<input type="submit" name="addDoctor"
class="button" value="add doctor" />
<input type="submit" name="showDoctor"
class="button" value="show doctor" />
<input type="submit" name="editDoctor"
class="button" value="edit doctor" />
<input type="submit" name="deleteDoctor"
class="button" value="delete doctor" />
</form>
<?php
echo '<body style="background-color:#383A59; color:white">';
if(array_key_exists('addDoctor', $_POST)) {
addDoctor();
}
else if(array_key_exists('showDoctor', $_POST)) {
showDoctor();
}
else if(array_key_exists('editDoctor', $_POST)) {
editDoctor();
}
else if(array_key_exists('deleteDoctor', $_POST)) {
deleteDoctor();
}
function addDoctor() {
echo '<form method="post" action="add_doctor.php">
ID: <input type="text" name="id"><br>
Name: <input type="text" name="name"><br>
Experience: <input type="text" name="experience"><br>
designation: <input type="text" name="designation"><br>
date_joined: <input type="text" name="date_joined"><br>
contact_number: <input type="text" name="contact_number"><br>
working_hours: <input type="text" name="working_hours"><br>
salary: <input type="text" name="salary"><br>
<input type="submit" value="commit">
</form>';
}
function editDoctor() {
echo '<form method="post" action="edit_doctor.php">
ID: <input type="text" name="id"><br>
Name: <input type="text" name="name"><br>
Experience: <input type="text" name="experience"><br>
designation: <input type="text" name="designation"><br>
date_joined: <input type="text" name="date_joined"><br>
contact_number: <input type="text" name="contact_number"><br>
working_hours: <input type="text" name="working_hours"><br>
salary: <input type="text" name="salary"><br>
<input type="submit" value="commit">
</form>';
}
function deleteDoctor() {
echo '<form method="post" action="delete_doctor.php">
ID: <input type="text" name="id"><br>
<input type="submit" value="commit">
</form>';
}
function showDoctor() {
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "doctor";
$mysqli = new mysqli("localhost", $username, $password, $database);
echo "<h2>DOCTOR</h2><ol>";
$query = "SELECT * FROM doctor";
$result = $mysqli->query($query);
echo '<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td> <font face="Monospace">ID</font> </td>
<td> <font face="Monospace">NAME</font> </td>
<td> <font face="Monospace">EXPERIENCE</font> </td>
<td> <font face="Monospace">DESIGNATION</font> </td>
<td> <font face="Monospace">DATE JOINED</font> </td>
<td> <font face="Monospace">CONTACT NUMBER</font> </td>
<td> <font face="Monospace">WORKING HOURS</font> </td>
<td> <font face="Monospace">SALARY</font> </td>
</tr>';
while ($row = $result->fetch_assoc()) {
$field1name = $row["id"];
$field2name = $row["name"];
$field3name = $row["experience"];
$field4name = $row["designation"];
$field5name = $row["date_joined"];
$field6name = $row["contact_number"];
$field7name = $row["working_hours"];
$field8name = $row["salary"];
echo '<tr>
<td> <font face="Monospace">'.$field1name.'</td>
<td> <font face="Monospace">'.$field2name.'</td>
<td> <font face="Monospace">'.$field3name.'</td>
<td> <font face="Monospace">'.$field4name.'</td>
<td> <font face="Monospace">'.$field5name.'</td>
<td> <font face="Monospace">'.$field6name.'</td>
<td> <font face="Monospace">'.$field7name.'</td>
<td> <font face="Monospace">'.$field8name.'</td>
</tr>';
}
$result->free();
echo "</ol>";
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
}
?>
</body>
</html>
<html>
<body>
ID <?php echo $_POST["id"]; ?><br>
Type <?php echo $_POST["type"]; ?><br>
Patient_ID <?php echo $_POST["patient_id"]; ?><br>
Amount <?php echo $_POST["amount"]; ?><br>
Date <?php echo $_POST["date"]; ?><br>
Contact <?php echo $_POST["contact_number"]; ?><br>
<?php
$BILLINGID=$_POST["id"];
$BILLINGTYPE=$_POST["type"];
$BILLINGPATIENT_ID=$_POST["patient_id"];
$BILLINGAMOUNT=$_POST["amount"];
$BILLINGDATE=$_POST["date"];
$BILLINGCONTACT=$_POST["contact_number"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "billing";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "UPDATE billing set id = '$BILLINGID', type = '$BILLINGTYPE', patient_id = '$BILLINGPATIENT_ID', amount = '$BILLINGAMOUNT', date = '$BILLINGDATE', contact_number='$BILLINGCONTACT' where id = '$BILLINGID'";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully edited<br>";
echo "$BILLINGID<br>";
echo "$BILLINGTYPE<br>";
echo "$BILLINGPATIENT_ID<br>";
echo "$BILLINGAMOUNT<br>";
echo "$BILLINGDATE<br>";
echo "$BILLINGCONTACT<br>";
echo '<form method="post" action="billing.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO UPDATE DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<html>
<body>
<?php
echo '<body style="background-color:#383A59; color:white">';
$DOCTORID=$_POST["id"];
$DOCTORNAME=$_POST["name"];
$DOCTOREXPERIENCE=$_POST["experience"];
$DOCTORDESIGNATION=$_POST["designation"];
$DOCTORDATEJOINED=$_POST["date_joined"];
$DOCTORCONTACTNUMBER=$_POST["contact_number"];
$DOCTORWORKINGHOURS=$_POST["working_hours"];
$DOCTORSALARY=$_POST["salary"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "doctor";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "update doctor set id = '$DOCTORID', name = '$DOCTORNAME', experience = '$DOCTOREXPERIENCE', designation = '$DOCTORDESIGNATION', date_joined = '$DOCTORDATEJOINED',contact_number='$DOCTORCONTACTNUMBER',working_hours = '$DOCTORWORKINGHOURS',salary='$DOCTORSALARY' where id = '$DOCTORID'";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully added<br>";
echo "$DOCTORID<br>";
echo "$DOCTORNAME<br>";
echo "$DOCTOREXPERIENCE<br>";
echo "$DOCTORDESIGNATION<br>";
echo "$DOCTORDATEJOINED<br>";
echo "$DOCTORCONTACTNUMBER<br>";
echo "$DOCTORWORKINGHOURS<br>";
echo "$DOCTORSALARY<br>";
echo '<form method="post" action="doctor.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO UPDATE DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<html>
<body>
<?php
echo '<body style="background-color:#383A59; color:white">';
$PATIENTID=$_POST["id"];
$PATIENTNAME=$_POST["name"];
$PATIENTADDRESS=$_POST["address"];
$PATIENTCONTACT=$_POST["contact_number"];
$PATIENTGENDER=$_POST["gender"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "emergency_patient";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "update emergency_patient set id = '$PATIENTID', name = '$PATIENTNAME', address = '$PATIENTADDRESS', contact_number = '$PATIENTCONTACT', gender = '$PATIENTGENDER' where id = '$PATIENTID'";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully edited<br>";
echo "$PATIENTID<br>";
echo "$PATIENTNAME<br>";
echo "$PATIENTADDRESS<br>";
echo "$PATIENTCONTACT<br>";
echo "$PATIENTGENDER<br>";
echo '<form method="post" action="epatient.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO UPDATE DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<html>
<body>
<?php
echo '<body style="background-color:#383A59; color:white">';
$PATIENTID=$_POST["id"];
$PATIENTNAME=$_POST["name"];
$PATIENTADDRESS=$_POST["address"];
$PATIENTCONTACT=$_POST["contact_number"];
$PATIENTGENDER=$_POST["gender"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "patient";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "update patient set id = '$PATIENTID', name = '$PATIENTNAME', address = '$PATIENTADDRESS', contact_number = '$PATIENTCONTACT', gender = '$PATIENTGENDER' where id = '$PATIENTID'";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully edited<br>";
echo "$PATIENTID<br>";
echo "$PATIENTNAME<br>";
echo "$PATIENTADDRESS<br>";
echo "$PATIENTCONTACT<br>";
echo "$PATIENTGENDER<br>";
echo '<form method="post" action="patient.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO UPDATE DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<html>
<body>
<?php
echo '<body style="background-color:#383A59; color:white">';
$SURGERYID=$_POST["id"];
$PATIENTID=$_POST["patient_id"];
$PATIENTNAME=$_POST["patient_name"];
$TIMEOFSURGERY=$_POST["time_of_surgery"];
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "patient";
$mysqli = new mysqli("localhost", $username, $password, $database);
$query = "update surgery set id = '$SURGERYID', patient_id = '$PATIENTID', patient_name = '$PATIENTNAME', time_of_surgery = '$TIMEOFSURGERY' where id = '$SURGERYID'";
$result = $mysqli->query($query);
if ($result == 1){
echo "successfully edited<br>";
echo "$SURGERYID<br>";
echo "$PATIENTID<br>";
echo "$PATIENTNAME<br>";
echo "$TIMEOFSURGERY<br>";
echo '<form method="post" action="surgery.php">
<input type="submit" value="go back">
</form>';
} else {
echo "FAILED TO UPDATE DATA<br>";
}
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>Hospital</h1>
<form method="post">
<input type="submit" name="addEpatient"
class="button" value="add emergency patient" />
<input type="submit" name="showEpatient"
class="button" value="show emergency patient" />
<input type="submit" name="editEpatient"
class="button" value="edit emergency patient" />
<input type="submit" name="deleteEpatient"
class="button" value="delete emergency patient" />
</form>
<?php
echo '<body style="background-color:#383A59; color:white">';
if(array_key_exists('addEpatient', $_POST)) {
addEpatient();
}
else if(array_key_exists('showEpatient', $_POST)) {
showEpatient();
}
else if(array_key_exists('editEpatient', $_POST)) {
editEpatient();
}
else if(array_key_exists('deleteEpatient', $_POST)) {
deleteEpatient();
}
function addEpatient() {
echo '<form method="post" action="add_epatient.php">
ID: <input type="text" name="id"><br>
Name: <input type="text" name="name"><br>
Address: <input type="text" name="address"><br>
Contact: <input type="text" name="contact_number"><br>
Gender: <input type="text" name="gender"><br>
<input type="submit" value="commit">
</form>';
}
function editEpatient() {
echo '<form method="post" action="edit_epatient.php">
ID: <input type="text" name="id"><br>
Name: <input type="text" name="name"><br>
Address: <input type="text" name="address"><br>
Contact: <input type="text" name="contact_number"><br>
Gender: <input type="text" name="gender"><br>
<input type="submit" value="commit">
</form>';
}
function deleteEpatient() {
echo '<form method="post" action="delete_epatient.php">
ID: <input type="text" name="id"><br>
<input type="submit" value="commit">
</form>';
}
function showEpatient() {
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "emergency_patient";
$mysqli = new mysqli("localhost", $username, $password, $database);
echo "<h2>EMERGENCY PATIENT</h2><ol>";
$query = "SELECT * FROM emergency_patient";
$result = $mysqli->query($query);
echo '<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td> <font face="Monospace">ID</font> </td>
<td> <font face="Monospace">Name</font> </td>
<td> <font face="Monospace">Address</font> </td>
<td> <font face="Monospace">Contact Number</font> </td>
<td> <font face="Monospace">Gender</font> </td>
</tr>';
while ($row = $result->fetch_assoc()) {
$field1name = $row["id"];
$field2name = $row["name"];
$field3name = $row["address"];
$field4name = $row["contact_number"];
$field5name = $row["gender"];
echo '<tr>
<td> <font face="Monospace">'.$field1name.'</td>
<td> <font face="Monospace">'.$field2name.'</td>
<td> <font face="Monospace">'.$field3name.'</td>
<td> <font face="Monospace">'.$field4name.'</td>
<td> <font face="Monospace">'.$field5name.'</td>
</tr>';
}
$result->free();
echo "</ol>";
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
}
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>Hospital</h1>
<form method="post">
<input type="submit" name="addPatient"
class="button" value="add patient" />
<input type="submit" name="showPatient"
class="button" value="show patient" />
<input type="submit" name="editPatient"
class="button" value="edit patient" />
<input type="submit" name="deletePatient"
class="button" value="delete patient" />
</form>
<?php
echo '<body style="background-color:#383A59; color:white">';
if(array_key_exists('addPatient', $_POST)) {
addPatient();
}
else if(array_key_exists('showPatient', $_POST)) {
showPatient();
}
else if(array_key_exists('editPatient', $_POST)) {
editPatient();
}
else if(array_key_exists('deletePatient', $_POST)) {
deletePatient();
}
function addPatient() {
echo '<form method="post" action="add_patient.php">
ID: <input type="text" name="id"><br>
Name: <input type="text" name="name"><br>
Address: <input type="text" name="address"><br>
Contact: <input type="text" name="contact_number"><br>
Gender: <input type="text" name="gender"><br>
<input type="submit" value="commit">
</form>';
}
function showPatient() {
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "patient";
$mysqli = new mysqli("localhost", $username, $password, $database);
echo "<h2>PATIENT</h2><ol>";
$query = "SELECT * FROM patient";
$result = $mysqli->query($query);
echo '<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td> <font face="Monospace">Name</font> </td>
<td> <font face="Monospace">ID</font> </td>
<td> <font face="Monospace">Address</font> </td>
<td> <font face="Monospace">Contact Number</font> </td>
<td> <font face="Monospace">Gender</font> </td>
</tr>';
while ($row = $result->fetch_assoc()) {
$field1name = $row["id"];
$field2name = $row["name"];
$field3name = $row["address"];
$field4name = $row["contact_number"];
$field5name = $row["gender"];
echo '<tr>
<td> <font face="Monospace">'.$field1name.'</td>
<td> <font face="Monospace">'.$field2name.'</td>
<td> <font face="Monospace">'.$field3name.'</td>
<td> <font face="Monospace">'.$field4name.'</td>
<td> <font face="Monospace">'.$field5name.'</td>
</tr>';
}
$result->free();
echo "</ol>";
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
}
function editPatient(){
echo '<form method="post" action="edit_patient.php">
ID: <input type="text" name="id"><br>
Name: <input type="text" name="name"><br>
Address: <input type="text" name="address"><br>
Contact: <input type="text" name="contact_number"><br>
Gender: <input type="text" name="gender"><br>
<input type="submit" value="commit">
</form>';
}
function deletePatient(){
echo '<form method="post" action="delete_patient.php">
ID: <input type="text" name="id"><br>
<input type="submit" value="commit">
</form>';
}
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>Hospital</h1>
<form method="post">
<input type="submit" name="addSurgery"
class="button" value="add surgery" />
<input type="submit" name="showSurgery"
class="button" value="show surgery" />
<input type="submit" name="editSurgery"
class="button" value="edit surgery" />
<input type="submit" name="deleteSurgery"
class="button" value="delete surgery" />
</form>
<?php
echo '<body style="background-color:#383A59; color:white">';
if(array_key_exists('addSurgery', $_POST)) {
addSurgery();
}
else if(array_key_exists('showSurgery', $_POST)) {
showSurgery();
}
else if(array_key_exists('editSurgery', $_POST)) {
editSurgery();
}
else if(array_key_exists('deleteSurgery', $_POST)) {
deleteSurgery();
}
function addSurgery() {
echo '<form method="post" action="add_surgery.php">
ID: <input type="text" name="id"><br>
Patient ID: <input type="text" name="patient_id"><br>
Patient Name: <input type="text" name="patient_name"><br>
Time Of Surgery: <input type="text" name="time_of_surgery"><br>
<input type="submit" value="commit">
</form>';
}
function showSurgery() {
try {
$username = "root";
$password = "password";
$database = "hospital";
$table = "patient";
$mysqli = new mysqli("localhost", $username, $password, $database);
echo "<h2>SURGERY</h2><ol>";
$query = "SELECT * FROM surgery";
$result = $mysqli->query($query);
echo '<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td> <font face="Monospace">ID</font> </td>
<td> <font face="Monospace">Patient ID</font> </td>
<td> <font face="Monospace">Patient Name</font> </td>
<td> <font face="Monospace">Time Of Surgery</font> </td>
</tr>';
while ($row = $result->fetch_assoc()) {
$field1name = $row["id"];
$field2name = $row["patient_id"];
$field3name = $row["patient_name"];
$field4name = $row["time_of_surgery"];
echo '<tr>
<td> <font face="Monospace">'.$field1name.'</td>
<td> <font face="Monospace">'.$field2name.'</td>
<td> <font face="Monospace">'.$field3name.'</td>
<td> <font face="Monospace">'.$field4name.'</td>
</tr>';
}
$result->free();
echo "</ol>";
} catch (mysqli_sql_exception $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
}
function editSurgery() {
echo '<form method="post" action="edit_surgery.php">
ID: <input type="text" name="id"><br>
Patient ID: <input type="text" name="patient_id"><br>
Patient Name: <input type="text" name="patient_name"><br>
Time Of Surgery: <input type="text" name="time_of_surgery"><br>
<input type="submit" value="commit">
</form>';
}
function deleteSurgery() {
echo '<form method="post" action="delete_surgery.php">
ID: <input type="text" name="id"><br>
<input type="submit" value="commit">
</form>';
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment