We are building up a doctor appointment system where patients can book and cancel appointments. We are making sure they cancel their appointments with their phone number and a message goes to them. However, in this case any phone which is typed, the message goes. Disregarding if the patient's name is there or not.
For example, if any patient in the database does not have any phone number of "9845654362" but in the cancel appointment page, I type "9845654362" in the form, the message will go to the sim. How can an appointment be cancelled if its not even there? How do we resolve this?
This is the php code for the design:
<html>
<body>
<div class="logo">
<img src="logo1.png" height="50px" width="50px" style="float:left">
<a style="font-size:40px; font-weight:bold;color:teal" >MUKUND ORTHOPAEDIC CENTER</a>
</div>
<br></br>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li class="active"><a href="maincancel.php">Back</a></li>
<li class="active"><a href="abc.html">Home</a></li>
</ul>
</div>
</nav>
<?php
// Create connection
$conn=mysqli_connect("localhost","root","","bookingcalendar");// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$phone= $_POST['phone'];
// sql to delete a record
$sql = "DELETE FROM bookings WHERE phone='$phone'";
if (mysqli_query($conn, $sql)) {
echo "<h3 align=\"center\" >Your slot has been cancelled successfully!";
} else {
echo "Error deleting record: " . mysqli_error($conn);
}
mysqli_close($conn);
$ph=(int)$phone;
$curl = curl_init();
$msg="Dear '$name', your appointment with Dr.Phaniraj is cancelled for '$date'";
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.fast2sms.com/dev/bulk?authorization=urFfV4mgSqRyNAH7M9cItCjedvYo5h8x6aDsLip3wKTO1GkzEXZYFspaQL1MAkjiPWy9GrCw34Kov5tx&sender_id=CHKSMS&message=".urlencode($msg)."&language=english&route=p&numbers=".$ph,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} //else {
//echo $response;
//}
?>
<br><h3><center><b>Click here to Reschedule Appointment:</b></center></h3>
<center><button><a href="index.php">Click here</a></button></center>
enter code here