Send e-mail to inbox using the submit button with filled-in form data

0

I have the following code, where when I finish filling out the form I want to receive an email with confirmation of the data and later open a page where I will redirect:

However, after the code that I present I have some difficulties in finishing;

Can you help?

<h2><td><font color ="#336699"> Formulario</td></font></h2>
<form action="http://www.teste.com/" id="ContactUsCaptchaWebForm"    method="post" onsubmit="return ValidateForm(this);" target="_top">
     <input name="skip_WhereToSend" type="hidden" value="[email protected]"/>
     <input name="skip_SnapHostID" type="hidden" value="D2YEXZTGA4Q2" />
     <input name="skip_WhereToReturn" type="hidden" value="http://www.torangis.com/" />
     <input name="skip_Subject" type="hidden" value="Contact Us Form" />
     <input name="skip_ShowUsersIp" type="hidden" value="1" />
     <input name="skip_SendCopyToUser" type="hidden" value="1" />
     <script type="text/javascript">
         function ValidateForm(frm) {
             if (frm.Name.value == "") {alert('Nome é requerido');frm.Name.focus();return false;}
             if (frm.Email.value == "") {alert('É necessário preencher os campos obrigatórios');frm.Email.focus();return false;}
             if (frm.Email.value.indexOf("@") < 1 || frm.Email.value.indexOf(".") < 1) {alert('É necessário um endereço de e-mail válido');frm.Email.focus();return false;}
             if (frm.Telemovel.value == "") {alert('É necessário preencher os campos obrigatórios');frm.Telemovel.focus();return false;}
             if (frm.skip_CaptchaCode.value == "") {alert('É necessário preencher os campos obrigatórios');frm.skip_CaptchaCode.focus();return false;}
             return true; }
        function ReloadCaptchaImage(captchaImageId) {
             var obj = document.getElementById(captchaImageId);
             var src = '' + obj.src;
             obj.src = '';
             var date = new Date();
             var pos = src.indexOf('&rad=');
             if (pos >= 0) { src = src.substr(0, pos); }
             obj.src = src + '&rad=' + date.getTime();
             return false; }
    </script>
    <table border="0" cellpadding="5" cellspacing="0" width="600">
        <tr>
            <td><font face="Arial"><font color ="#000000"> Nome *</td></font>
            <td><input name="Name" type="text" maxlength="60" style="width:350px;" /></td>
       </tr><tr>
            <td><font face="Arial"><font color ="#000000"> E-mail *</td></font>
            <td><input name="Email" type="text" maxlength="60" style="width:350px;" /></td>
      </tr><tr>
           <td><font face="Arial"><font color ="#000000"> Empresa / Loja (Se aplicável) </td></font>
           <td><input name="Empresa" type="text" maxlength="43" style="width:350px;" /></td>
      </tr><tr>
           <td><font face="Arial"><font color ="#000000"> Concelho </td></font>
           <td><input name="Concelho" type="text" maxlength="60" style="width:350px;" /></td>
     </tr><tr>
           <td><font face="Arial"><font color ="#000000"> Telemóvel *</td></font>
           <td><input name="Telemovel" type="text" maxlength="43" style="width:350px;" /></td>
     </tr><tr>
           <td><font face="Arial"><font color ="#000000"> Mensagem opcional </td></font>
           <td><textarea name="Comentario" rows="4" cols="50" style="width:350px;"></textarea></td>
    </tr><tr>
          <td colspan="2" align="center"> <br />
          <table border="0" cellpadding="0" cellspacing="0">
    <tr>
          <td colspan="2" style="padding-bottom:18px;">
              <tr valign="top"><td> <b><font face="Arial"><font size="2"><center>Inserir letras *</center></b>
              <input name="skip_CaptchaCode" type="text" style="width:80px;" maxlength="6" />
              </td><td>
                  <a href="http://www.teste.com/"><img id="CaptchaImage" alt="Contact Us form" title="HTML code for Contact Us form" style="margin-left:20px;"  src="http://www.SnapHost.com/captcha/CaptchaImage.aspx?id=D2YEXZTGA4Q2&ImgType=2"/></a><br/><ahref="#" onclick="return ReloadCaptchaImage('CaptchaImage');"><span style="font-size:12px;"><font face="Arial">Renovar imagem</span></a> </td></tr>
        </table> <br /><font face="Arial">
        * Campos obrigatórios &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        <form enctype="text/plain" method="get" action="mailto:[email protected]">
             <input type="submit" value="Enviar">
        </form>
    </td></tr>
    </table><br />
</form>


<html>
    <head>
        <?php $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; 
        $empresa = $_REQUEST['empresa'] ; $telefone = $_REQUEST['telefone'] ;
        $concelho = $_REQUEST['concelho'] ; $message = $_REQUEST['message'] ;
        mail( "[email protected]", 
        "Quero fazer activações através do teste da teste",
        "#REVENDEDOR         ################################################################ 
        EMPRESA/LOJA:$empresa NOME:$name EMAIL: $email TELEFONE: $telefone 
        CONCELHO:$concelho MENSAGEM: $message ", "from: [email protected]"); 
        header( "Location: http://teste.teste.com/resposta2.php" ); ?>
    </head>
    <body>
        <br>
    </body>
</html>

Thank you

    
asked by anonymous 14.09.2017 / 11:29

1 answer

0

To facilitate, create a separate file for the submission, the way it is it would try to send whenever the html is executed.

send_email.php

<?php 
    $name = $_REQUEST['name'] ; 
    $email = $_REQUEST['email'] ; 
    $empresa = $_REQUEST['empresa'] ; 
    $telefone = $_REQUEST['telefone'] ;
    $concelho = $_REQUEST['concelho'] ; 
    $message = $_REQUEST['message'] ;

    @mail( "[email protected]", 
    "Quero fazer activações através do teste da teste",
    "#REVENDEDOR         ################################################################ 
    EMPRESA/LOJA:$empresa NOME:$name EMAIL: $email TELEFONE: $telefone     CONCELHO: 
    $concelho MENSAGEM: $message ", "from: [email protected]"); 

    header("Location: http://teste.teste.com/resposta2.php"); 
?>

in your .html file

Replace your form action with: <form action="http://www.teste.com/enviar_email.php" [...]>

Remembering that to test locally you need a configured smtp server; when you use From: ... , and the email will not be valid or will not be part of your well-known domain that will receive as a span, or will not even receive depending on the server that receives the email. p>     

14.09.2017 / 14:07