Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda