Place more than one SUBMIT input in HTML form

0

I have on my page a form with an already determined action and an input button.

<form id="educForm1" name="educForm1" action="<?php echo ROOT . 'educacao' ?>/enviaemail" method="post" enctype="multipart/form-data">
...
    <input id="enviaEmail" name="enviaEmail" type="submit" class="textDescricaoSobre font13" value="Criar Evento" style="cursor: pointer; width: 90px;" />
</form>

When you press this button, it sends E-mail, it should save the form data in the database table and automatically send an e-mail with the recorded data.

I'd like to put a second submit, which would only send the email and not record it in the bank. The first submit would only save the data, but you should not refresh the page in the action (action = php echo ROOT. 'Education' / enviaemail).

What could I do? Change the action of the action? Put button or instead of input? I'm open to suggestions.

    
asked by anonymous 07.06.2016 / 19:36

1 answer

1

Use the checkbox or a select (yes / no) in the form to indicate whether or not the record should be saved in the database.

How to send email is mandatory, divide the code into at least two functions one that writes to the bank and another that sends the email, so the main flow of the program is very simple.

Something like:

<?php
   $msg = enviarEmail($dadosForm); //retorna uma string sucesso ou falha.
   if($_POST['insert'] == 'sim'){
      gravarNoBanco($dadosForm);
   }

   echo $msg;
    
07.06.2016 / 20:06