I have an HTML table and in one of its cells, there is a button to Accept food orders. That data is then checked by another PHP page if it's ok or not and then the data is updated accordingly. Below is the code I used for the HTML table button:
.
.
//codes
.
.
<td>
<center>".$totalamount."</center></td>
<td><center>".$payment_mode."</center></td>
<td><center>".$datetime."</center></td>
<td><center><a class='btn btn-primary' href='orderstatus.php?orderid=".$orderid."&orderstatus=Accept'>Accept</center></a>
</td>";?>
</tr>
As you can see the last <td> cell consists of the button which links to another PHP page orderstatus.php. Below is the code for this page:
.
.
//codes
.
.
while($data2 = mysqli_fetch_array($userinfocon))
{
$username=$data2['username'];
$useremail=$data2['email'];
}
if($orderstatus=="Accept")
{
//codes
}
if($orderstatus=="InKitchen")
{
//codes
}
if($orderstatus=="Ready")
//codes
Now I want that whenever the status is a particular value or whenever a button is clicked it should send an email to the user using PHPMailer() about their order status.
I tried to do it by adding the PHP mailing code after every if-else statement but that ends up creating a loop that keeps on sending me emails.
I am a beginner in PHP so I am not able to understand what should be done.