Send email to inbox via send button with completed form data

Asked

Viewed 65 times

0

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

However, after the code I present I’m having some difficulty finishing;

Can 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 />
                  <a href="#" 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 very much

  • What would be the PHP code that would send the email?

  • Would that be: <? php $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $company = $_REQUEST['company'] ; $phone = $_REQUEST['phone'] ; $county = $_REQUEST['county'] ; $message = $_REQUEST['message'] ; mail( "[email protected]") COMPANY/STORE:$company NAME:$name EMAIL: $email PHONE: $phone COUNTY: $county MESSAGE: $message ", "from: [email protected]"); header( "Location: http://www.teste.com/resposta.php" ); ?>

  • Put together the question this code

  • I don’t understand, how do I put the question together?

  • In the same way that you put HTML, just [Edit] the question.

  • Thanks for the help, I already put the code at the end.

  • Know what function to give the error result when the Captcha image is different than what I have in the text box?

Show 2 more comments

1 answer

0

To make it easy, create a separate file for sending, the way it is it would try to send whenever html is run.

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" [...]>

Remember that to test locally you need a configured smtp server; when you use From: ..., and the email is not valid or is not part of your very certain domain that you will receive as span, or will not receive depending on the server that receives the email.

  • Thank you so much for your help! Continuation of great day.

  • Do you know the function to give the error result when the Captcha image is different than what I have in the text box? At the moment any value is accepted, and I do not know what function to use.

  • Your questions have been very vague, you use some framework; you who made the captcha; what kind of mistake you speak?

Browser other questions tagged

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