How to send multiple different data by email?

0

Good evening,

And the next I have a system with 3 input and I have a jquery that adds me 3 more if I wanted to send more data I am being able to email the data of the first three but when I add 3 more already does not send me the value of the 3 he added.

Form

<table id="add_estabelecimento_table" border="0" style="margin: 0px 0px 20px 0px;" cellspacing="0" cellpadding="0">
    <tr>
        <td valign="top">
            <div style="margin:0px 20px 0px 0px; width: 267px; "><input placeholder="País" type="text"  name="input_anuncia[]"></div>  
        </td>
        <td valign="top">
            <div style="margin:0px 20px 0px 0px; width: 267px; "><input placeholder="Nome do Estabelecimento" type="text" name="input_anuncia[]"></div> 
        </td>
        <td valign="top" >
            <div style="margin:0px 20px 0px 0px; width: 267px;"><input placeholder="Localização" type="text" name="input_anuncia[]"></div> 
        </td>
    </tr>
</table>

Code where I treat the value of the post

foreach ($_REQUEST['input_anuncia'] as $dados_local ) {

  $mostra_dados_local = '
     <div class="movableContent">
        <table width="580" border="0" cellspacing="0" cellpadding="0" align="center">
          <tr><td height="40"></td></tr>
          <tr>
            <td style="border: 1px solid #EEEEEE; border-radius:6px;-moz-border-radius:6px;-webkit-border-radius:6px">
              <table width="480" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr><td height="25"></td></tr>
                <tr>
                  <td>
                    <div class="contentEditableContainer contentTextEditable">
                      <div class="contentEditable" style="text-align: center;">
                        <h2 style="font-size: 20px;">Dados do Estabelecimento</h2>
                        <br>
                           <table width="100%" border="0" cellspacing="0" cellspacing="0">
                            <tr>
                                <td valign="top">
                                  <div style="font-size: 13px; font-weight: bold; float:left;">País:</div>
                                </td>
                                <td valign="top">
                                  <p>'.$_REQUEST['input_anuncia'][0].'</p>
                                </td>
                            </tr>
                            <tr>
                                <td valign="top">
                                  <div style="font-size: 13px; font-weight: bold; float:left;">Nome do Estabelecimento:</div>
                                </td>
                                <td valign="top">
                                  <p>'.$_REQUEST['input_anuncia'][1].'</p>
                                </td>
                            </tr>
                            <tr>
                                <td valign="top"> 
                                  <div style="font-size: 13px; font-weight: bold; float:left;">Localização</div>
                                </td>
                                <td valign="top">
                                  <p>'.$_REQUEST['input_anuncia'][2].'</p>
                                </td>
                            </tr>
                        </table>
                      </div>
                    </div>
                  </td>
                </tr>
                <tr><td height="24"></td></tr>
              </table>
             </td>
          </tr>
        </table>
      </div>   
  ';
}
    
asked by anonymous 20.03.2015 / 02:54

1 answer

2

First, you should change the form a little to make things easier:

<table id="add_estabelecimento_table" border="0" style="margin: 0px 0px 20px 0px;" cellspacing="0" cellpadding="0">
    <tr>
        <td valign="top">
            <div style="margin:0px 20px 0px 0px; width: 267px; "><input placeholder="País" type="text"  name="input_pais[]"></div>  
        </td>
        <td valign="top">
            <div style="margin:0px 20px 0px 0px; width: 267px; "><input placeholder="Nome do Estabelecimento" type="text" name="input_nome[]"></div> 
        </td>
        <td valign="top" >
            <div style="margin:0px 20px 0px 0px; width: 267px;"><input placeholder="Localização" type="text" name="input_local[]"></div> 
        </td>
    </tr>
</table>

Notice that I changed the name of the inputs, to know what it is (I could keep the same, but I would have to multiply everything by 3 to use the right fields)

Then, in the part that processes the data you set the loop in this part:

$qtd = count( $_REQUEST['input_pais'] );
for ( $i = 0; $i < $qtd ; $i++ ) {

and here change the variables and put the indexes:

                            <td valign="top">
                              <p>'.$_REQUEST['input_pais'][$i].'</p>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top">
                              <div style="font-size: 13px; font-weight: bold; float:left;">Nome do Estabelecimento:</div>
                            </td>
                            <td valign="top">
                              <p>'.$_REQUEST['input_nome'][$i].'</p>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top"> 
                              <div style="font-size: 13px; font-weight: bold; float:left;">Localização</div>
                            </td>
                            <td valign="top">
                              <p>'.$_REQUEST['input_local'][$i].'</p>
                            </td>
                        </tr>

So, the code will be repeated for the right amount of form data.

IMPORTANT: I did not want to leave the answer very confused, but you can greatly simplify this your HTML, and just repeat the TR part, instead of the entire div. Try to understand and make it work this way, but then try to optimize the code.

    
20.03.2015 / 03:26