I would like to put my send_sms on an if else of two buttons. If a button 'accept' will be clicked, an sms will be sent on an number in the php table containing a message "Accepted". Such as on 'reject' button the message will also be sent to a number but the message will be "Rejected". Please Help..Thank you in advance.
Here's my php code it names app.php
<?php
//connect to database
$con = mysqli_connect('127.0.0.1','root','');
//select database
mysqli_select_db($con, 'appointment');
//select query
$sql = "SELECT * FROM service";
//Execute the query
$records = mysqli_query($con,$sql)
?>
<html>
<head>
<title>Appointment Schedule</title>
</head>
<body>
<table width = "100%" border = "5px" height = "20%">
<tr align = "left">
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Address</th>
<th>Date</th>
<th>Time</th>
<th>Office</th>
<th>Service</th>
<th>Contact No.</th>
<th>Remarks</th>
</tr>
<?php
while($row = mysqli_fetch_array($records))
{
echo "<tr><form action = 'display.php' method = post>";
echo "<input type=hidden name=id value='".$row['ID']."'>";
echo "<td>".$row['fname']."</td>";
echo "<td>".$row['mname']."</td>";
echo "<td>".$row['lname']."</td>";
echo "<td>".$row['address']."</td>";
echo "<td>".$row['date']."</td>";
echo "<td>".$row['time']."</td>";
echo "<td>".$row['office']."</td>";
echo "<td>".$row['services']."</td>";
echo "<td><name = number>".$row['contactno']."</td>";
echo "<td>".$row['remarks']."</td>";
if($row['remarks'] == 'Accepted' || $row['remarks'] == 'Rejected')
{
echo "<td><input type =submit disabled value='Accepted' name=accept>";
echo "<td><input type =submit disabled value='Rejected' name=reject>";
}
else
{
if echo "<td><input type =submit value='Accepted' name=accept>";
{
<form method="POST" action="send_sms.php"></form>
}
elseif echo "<td><input type =submit value='Rejected' name=reject>";
{
<form method="POST" action="send_sms1.php"></form>
}
}
echo "</form></tr>";
}
?>
</table>
</body>
</html>
Here's my SMS code it names send_sms.php
<?php
//connect to database
$con = mysqli_connect('127.0.0.1','root','');
//select database
mysqli_select_db($con, 'appointment');
$phone= mysql_query("SELECT contactno FROM service");
$message= "Your Appointment was Accepted";
send_sms($phone,$message);
function send_sms($phone, $message) {
$ch = curl_init();
$parameters = array(
'apikey' => '*****', //Your API KEY
'number' => $phone,
'message' => $message,
'sendername' => 'SEMAPHORE'
);
curl_setopt( $ch, CURLOPT_URL,'http://api.semaphore.co/api/v4/messages' );
curl_setopt( $ch, CURLOPT_POST, 1 );
//Send the parameters set above with the request
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $parameters ) );
// Receive response from server
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close ($ch);
//Show the server response
echo "Message Successfully Delivered";
}
?>
Here's the another one php code. It named send_sms1.php
<?php
//connect to database
$con = mysqli_connect('127.0.0.1','root','');
//select database
mysqli_select_db($con, 'appointment');
$phone= mysql_query("SELECT contactno FROM service");
$message= "Your Appointment was Rejected";
send_sms($phone,$message);
function send_sms($phone, $message) {
$ch = curl_init();
$parameters = array(
'apikey' => '******', //Your API KEY
'number' => $phone,
'message' => $message,
'sendername' => 'SEMAPHORE'
);
curl_setopt( $ch, CURLOPT_URL,'http://api.semaphore.co/api/v4/messages' );
curl_setopt( $ch, CURLOPT_POST, 1 );
//Send the parameters set above with the request
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $parameters ) );
// Receive response from server
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close ($ch);
//Show the server response
echo "Message Successfully Delivered";
}
?>
I'll provide a screenshot so that you can easily understand my problem sir/maam.