I can not make a field of the form be sent to the email with phpmailer [closed]

0

I have a form that has a field with a (select one menu) there are some options where the user should choose only one and select it this form sends the information to my email this functionality is already working but not I can make this field appear in the email also follow my code.

    <div id="formulario">
        <form action="email.php" method="post">
            <ul>
                <li><input type="text" name="Nome" id="nome" placeholder="  Digite seu nome" required name=nome ></li>
                <li><input type="text" name="Email" placeholder="  Digite seu Email" required name=email></li>
                <li><input type="text" name="Nickname" placeholder="  Digite seu Nickname" required name=nickname></li>
                <li>
                    <select name="Games">
                        <option value ="the-elder" selected>  --- Selecione um jogo ---</option>
                        <option value ="the-elder">The Elder Scrols Online</option>
                        <option value ="archage">ArcheAge</option>
                        <option value ="worlofwarcraft">World of War Craft </option>
                        <option value ="forsaken">Forsaken World</option>
                        <option value ="leagueoflegends">League of Legends</option>
                        <option value ="dota">Dota 2</option>
                        <option value ="smite">Smite</option>
                        <option value ="warface">Warface</option>
                        <option value ="cs">CS-GO</option>
                        <option value ="bf">Battle Field</option>
                        <option value ="cod">Call of Dutty</option>
                    </select>
                </li>
                <li><textarea placeholder="  Mensagem" name="Mensagem" required name=mensagem></textarea></li>
                <li><input type=submit value="Enviar" id="enviar" name="Enviar"/></li>
            </ul>
        </form>
    </div>

The php remembered that it is in a separate file and I am using phpmailer:

<?php
$Nome       = $_POST["Nome"];   // Pega o valor do campo Nome
$Nickname       = $_POST["Nickname"];   // Pega o valor do campo Telefone
$Email      = $_POST["Email"];  // Pega o valor do campo Email
$Mensagem   = $_POST["Mensagem"];   // Pega os valores do campo Mensagemgames
$Games  = $_POST["Games"];  // Pega os valores do campo Mensagemgames


// Variável que junta os valores acima e monta o corpo do email

$Vai        = "Nome: $Nome\n\nE-mail: $Email\n\nNicknamer: $Nickname\n\nMensagem: $Mensagem\n";

require_once("phpmailer/class.phpmailer.php");

define('GUSER', '[email protected]');   // <-- Insira aqui o seu GMail
define('GPWD', 'lalala123');        // <-- Insira aqui a senha do seu GMail

function smtpmailer($para, $de, $de_nome, $assunto, $corpo) { 
    global $error;
    $mail = new PHPMailer();
    $mail->IsSMTP();        // Ativar SMTP
    $mail->SMTPDebug = 2;       // Debugar: 1 = erros e mensagens, 2 = mensagens apenas
    $mail->SMTPAuth = true;     // Autenticação ativada
    $mail->SMTPSecure = 'ssl';  // SSL REQUERIDO pelo GMail
    $mail->Host = 'smtp.gmail.com'; // SMTP utilizado
    $mail->Port = 465;          // A porta 587 deverá estar aberta em seu servidor
    $mail->Username = GUSER;
    $mail->Password = GPWD;
    $mail->SetFrom($de, $de_nome);
    $mail->Subject = $assunto;
    $mail->Body = $corpo;
    $mail->AddAddress($para);
    if(!$mail->Send()) {
        $error = 'Mail error: '.$mail->ErrorInfo; 
        return false;
    } else {
        $error = 'Mensagem enviada!';
        return true;
    }
}

// Insira abaixo o email que irá receber a mensagem, o email que irá enviar (o mesmo da variável GUSER), 

 if (smtpmailer('[email protected]', '[email protected]', 'felipe', 'Recrutamento Nova Era', $Vai)) {

    Header("location:obrigado.html"); // Redireciona para uma página de obrigado.

}
if (!empty($error)) echo $error;
?>

The form field that I also want to appear in the email and I'm not getting it would be this:

<li>
  <select name="Games">
     <option value ="the-elder" selected>  --- Selecione um jogo ---</option>
     <option value ="the-elder">The Elder Scrols Online</option>
     <option value ="archage">ArcheAge</option>
     <option value ="worlofwarcraft">World of War Craft </option>
     <option value ="forsaken">Forsaken World</option>
     <option value ="leagueoflegends">League of Legends</option>
     <option value ="dota">Dota 2</option>
     <option value ="smite">Smite</option>
     <option value ="warface">Warface</option>
     <option value ="cs">CS-GO</option>
     <option value ="bf">Battle Field</option>
     <option value ="cod">Call of Dutty</option>
  </select>
</li>
    
asked by anonymous 28.05.2015 / 13:31

2 answers

1

You are not concatenating $Games into $Vai . Just do it like this:

$Vai = "Nome: $Nome\n\nE-mail: $Email\n\nNicknamer: $Nickname\n\nGame: $Games\n\nMensagem: $Mensagem\n";
    
28.05.2015 / 13:53
1

Your input has two attributes name like this textarea

<textarea placeholder="  Mensagem" name="Mensagem" required name=mensagem></textarea>

If you understand correctly you want to send a select field along with your email, add this line before sending the email:

$mail->IsHTML(true);

and concatenate your select to the email body:

$vai .= "<select name="Games"></select>";
    
28.05.2015 / 13:38