How to send multiple different data by email?

Asked

Viewed 65 times

0

Good night,

And the next one I have a system with 3 input and I have a jquery that adds me 3 more just in case I wanted to send more data I’m able to send by email the data of the first three but when I add 3 more no longer sends me the value of the 3 that 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 post value

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>   
  ';
}

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>

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

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

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

and here changes the variables and puts 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>

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

IMPORTANT: I didn’t want to confuse the answer too much, but you can simplify your HTML too much, and repeat only the TR part, instead of the entire div. Try to understand and make it work until this part, but then try to optimize the code.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.