Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

219
Visualizações
How to add PHPmailer in if else statement and send email through it with a button click?

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.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda