Eviando responses from a php poll via array to an email using the php mail function

Asked

Viewed 79 times

0

Good morning to everyone, I would like to know if I am receiving the values of my form correctly and sending by email using an array to list questions and answers of the poll.

follows the code.

 $meuArray = array( 0 => "$pergunta_principal", 1 => "$primeira_opcao", 2 => "$segunda_opcao", 3 => "$terceira_opcao", 4 => "$quarta_opcao");

                while($lista array($meuArray)) {

              .'<b>'. echo $lista['pergunta_principal'];.'<br/><br/>
                <b>Primeira Opção  R:</b> '.echo $lista['primeira_opcao'];.'<br/><br/>
                <b>Segunda Opção   R:</b> '.echo $lista['segunda_opcao'];.'<br/><br/>
                <b>Terceira Opção  R:</b> '.echo $lista['terceira_opcao'];.'<br/><br/>
                <b>Quarta Opção  R:</b> '.echo $lista['quarta_opcao'];.'<br/><br/>
                '
                } //fim do while
  • 1 - I don’t understand the use of while. 2 - There are many errors there, you are concatenating a string with the echo function, you are wrong. 3 - Improve the indentation. 4 - Use double quotes and throw the variables directly. 5 - Where is the code to send the email?

  • I’ll post it all ..

1 answer

0

 $Perguntas = array(
   "Primeira Opção"  => "$primeira_opcao",
   "Segunda Opção"   => "$segunda_opcao",
   "Terceira Opção"  => "$terceira_opcao",
   "Quarta Opção"    => "$quarta_opcao"
 );

 // cria variavel para armazenar as msgs.
 $msgParaEmail = '';


 foreach($Perguntas as $key => $p_valor) {
    $msgParaEmail .= '<b>'.$key.' R:</b> '.$p_valor.'<br/>';
 }

 // Função fictícia  
 enviarEmail([email protected],$msgParaEmail);
  • Showww but how to send by email ? I say the broken lines .. as the foreach will list understand.. and thank you in advance

  • I made an issue.

  • ai I did not understand type in $msgParaEmail = "" where it is empty I call a variable any ppra receive values ? or I leave as is ..

  • leaves as it is! I created it just to receive the data outside the scope of foreach...

  • Good morning, my dear is not taking the values from the form .. I forgot to tell you that this form there .. is a jquery effect.. where is the while he keeps repeating until the client ( administrator wants to stop asking questions.. understood. ) when he finishes.. the data comes to these variables and assembles the form.. until then is done, today mission to rescue these responses from this form that the administrator generated and send by email .

Browser other questions tagged

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