Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Forms. acition="codie@codie.com", how do i get it to submit to a email address

    Hi guys. I have made my form.

    But when the user clicks the submit button, I want the information they filled out to be emailed to a specified email address, but when I test this, I just get some weird error.

    This is the code for the top of my form

    Code:
    <form id="subForm" name="subForm" method="post" action="codie@codie.com">
    This is the code for my submit button

    Code:
    <input type="submit" name="joinFindatrade" id="joinFindatrade" value="Join findatrade" />
    Obviously I am missing something, but I am lost to what it is.

    Help would be much appreciated.

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    action="mailto:codie@codie.com"

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    It should be pointed out though that using the mailto in the form action will only work if the user's computer is configured to handle mailto links (by having an email client configured like Outlook or Thunderbird or etc.) and then they have to manually send the email off.

    This is generally not done because of those requirements, instead having your form submit to a server side script that sends the email from your server is a better idea.
    OracleGuy

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,677
    Thanks
    6
    Thanked 1,008 Times in 981 Posts
    To add to the last statement: Search the internet for “form mailer” or “php form mailer”, or something like that.

  • Users who have thanked VIPStephan for this post:

    thecodemeist3r (06-18-2008)

  • #5
    New Coder
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    5
    Thanked 0 Times in 0 Posts
    action="mailto:codie@codie.com"
    I have tryed that, its not really what I am looking for though.

    To add to the last statement: Search the internet for “form mailer” or “php form mailer”, or something like that.
    I have done this, and came accross this script:

    HTML:
    Code:
    <html>
    
    <head>
    <title>PHP Form Mailer - phpFormMailer (easy to use and more secure than many cgi form
    mailers)</title>
    <style>
    BODY{color:#000000; font-size: 8pt; font-family: Verdana}
    .button {background-color: rgb(128,128,128); color:#ffffff; font-size: 8pt;}
    .inputc {font-size: 8pt;}
    .style3 {font-size: xx-small}
    </style>
    </head>
    
    <body>
    
    <form name="phpformmailer" action="contact_process.php" align="center" method="post">
      <div align="center"><center><table bgcolor="#F2F2F2" width="742" cellspacing="6">
        <tr>
          <td width="162"><strong>Contact Us</strong></td>
          <td width="556"><span class="style3">Protected by: <a
          href="http://thedemosite.co.uk/phpformmailer/">phpFormMailer</a> the freely available PHP form mailer</span></td>
        </tr>
        <tr>
          <td align="right" width="162"><small>Your name:</small></td>
          <td width="556"><font face="Arial"><input class="inputc" size="50" name="name">
          </font></td>
        </tr>
        <tr>
          <td align="right" width="162"><font color="#000080" size="1">*</font><small> Your email
          address:</small></td>
          <td align="left" width="556"><font face="Arial"><input class="inputc" size="50"
          name="email">
          </font></td>
        </tr>
        <tr align="middle">
          <td align="right" width="162"><font color="#000080" size="1">*</font><small> Confirm email
          address:</small></td>
          <td width="556" align="left"><font face="Arial"><input class="inputc" size="50"
          name="email2">
          </font></td>
        </tr>
        <tr>
          <td align="right" width="162"><font color="#000080" size="1">*</font><small> Subject:</small></td>
          <td width="556"><font face="Arial"><input class="inputc" size="60" name="thesubject">
          </font></td>
        </tr>
        <tr>
          <td align="right" width="162">&nbsp;
            <p><font color="#000080" size="1">*</font><small> Your
          request or query:</small></td>
          <td width="556"><textarea style="FONT-SIZE: 10pt" name="themessage" rows="7" cols="60"></textarea></td>
        </tr>
        <tr>
          <td width="162"></td>
          <td width="556"><p>
            <input type="button" class="button"
          value="Send" name="B1" ONCLICK="javascript:validateForm()">
              <small> <small>You must fill in
            the fields marked with a *</p>
            </td>
        </tr>
      </table>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p><span class="style3">Protected by: <a
          href="http://thedemosite.co.uk/phpformmailer/">phpFormMailer</a> the freely available PHP form mailer</span></p>
      </center></div>
    </form>
    
    <script language="JavaScript"><!--
    function validateForm() 
    {
     var okSoFar=true
     with (document.phpformmailer)
     {
      var foundAt = email.value.indexOf("@",0)
      if (foundAt < 1 && okSoFar)
      {
        okSoFar = false
        alert ("Please enter a valid email address.")
        email.focus()
      }
      var e1 = email.value
      var e2 = email2.value
      if (!(e1==e2) && okSoFar)
      {
        okSoFar = false
        alert ("Email addresses you entered do not match.  Please re-enter.")
        email.focus()
      }
      if (thesubject.value=="" && okSoFar)
      {
        okSoFar=false
        alert("Please enter the subject.")
        thesubject.focus()
      }
      if (themessage.value=="" && okSoFar)
      {
        okSoFar=false
        alert("Please enter the details for your enquiry.")
        themessage.focus()
      }
      if (okSoFar==true)  submit();
     }
    }
    // --></script>
    </body>
    </html>
    And the PHP code:

    Code:
    <?php
    /* PHP Form Mailer - phpFormMailer v2.2, last updated 23rd Jan 2008 - check back often for updates!
       (easy to use and more secure than many cgi form mailers) FREE from:
                      www.TheDemoSite.co.uk
          Should work fine on most Unix/Linux platforms
          for a Windows version see: asp.thedemosite.co.uk
    */
    
    // ------- three variables you MUST change below  -------------------------------------------------------
    $replyemail="YOU@Your--domain";//change to your email address
    $valid_ref1="http://Your--domain/contact.html";// chamge "Your--domain" to your domain
    $valid_ref2="http://www.Your--domain/contact.html";// chamge "Your--domain" to your domain
    // -------- No changes required below here -------------------------------------------------------------
    // email variable not set - load $valid_ref1 page
    if (!isset($_POST['email']))
    {
     echo "<script language=\"JavaScript\"><!--\n ";
     echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
     exit;
    }
    
    $ref_page=$_SERVER["HTTP_REFERER"];
    $valid_referrer=0;
    if($ref_page==$valid_ref1) $valid_referrer=1;
    elseif($ref_page==$valid_ref2) $valid_referrer=1;
    if(!$valid_referrer)
    {
     echo "<script language=\"JavaScript\"><!--\n alert(\"ERROR - not sent.\\n\\nCheck your 'valid_ref1' and 'valid_ref2' are correct within contact_process.php.\");\n";
     echo "top.location.href = \"contact.html\"; \n// --></script>";
     exit;
    }
    
    //check user input for possible header injection attempts!
    function is_forbidden($str,$check_all_patterns = true)
    {
     $patterns[0] = 'content-type:';
     $patterns[1] = 'mime-version';
     $patterns[2] = 'multipart/mixed';
     $patterns[3] = 'Content-Transfer-Encoding';
     $patterns[4] = 'to:';
     $patterns[5] = 'cc:';
     $patterns[6] = 'bcc:';
     $forbidden = 0;
     for ($i=0; $i<count($patterns); $i++)
      {
       $forbidden = eregi($patterns[$i], strtolower($str));
       if ($forbidden) break;
      }
     //check for line breaks if checking all patterns
     if ($check_all_patterns AND !$forbidden) $forbidden = preg_match("/(&#37;0a|%0d|\\n+|\\r+)/i", $str);
     if ($forbidden)
     {
      echo "<font color=red><center><h3>STOP! Message not sent.</font></h3><br><b>
            The text you entered is forbidden, it includes one or more of the following:
            <br><textarea rows=9 cols=25>";
      foreach ($patterns as $key => $value) echo $value."\n";
      echo "\\n\n\\r</textarea><br>Click back on your browser, remove the above characters and try again.
            </b><br><br><br><br>Thankfully protected by phpFormMailer freely available from:
            <a href=\"http://thedemosite.co.uk/phpformmailer/\">http://thedemosite.co.uk/phpformmailer/</a>";
      exit();
     }
     else return $str;
    }
    
    $name = is_forbidden($_POST["name"]);
    $email = is_forbidden($_POST["email"]);
    $thesubject = is_forbidden($_POST["thesubject"]);
    $themessage = is_forbidden($_POST["themessage"], false);
    
    $success_sent_msg='<p align="center"><strong>&nbsp;</strong></p>
                       <p align="center"><strong>Your message has been successfully sent to us<br>
                       </strong> and we will reply as soon as possible.</p>
                       <p align="center">A copy of your query has been sent to you.</p>
                       <p align="center">Thank you for contacting us.</p>';
    
    $replymessage = "Hi $name
    
    Thank you for your email.
    
    We will endeavour to reply to you shortly.
    
    Please DO NOT reply to this email.
    
    Below is a copy of the message you submitted:
    --------------------------------------------------
    Subject: $thesubject
    Query:
    $themessage
    --------------------------------------------------
    
    Thank you";
    
    $themessage = "name: $name \nQuery: $themessage";
    mail("$replyemail",
         "$thesubject",
         "$themessage",
         "From: $email\nReply-To: $email");
    mail("$email",
         "Receipt: $thesubject",
         "$replymessage",
         "From: $replyemail\nReply-To: $replyemail");
    echo $success_sent_msg;
    /*
      PHP Form Mailer - phpFormMailer (easy to use and more secure than many cgi form mailers)
       FREE from:
    
        www.TheDemoSite.co.uk       */
    ?>
    The link to the site is: http://www.thedemosite.co.uk/phpform...rm_mailers.php

    But it doesnt tell me how I can go about implementing this into my form.

    Help would be much appreciated. Thanks.

  • #6
    Regular Coder FWDrew's Avatar
    Join Date
    Apr 2008
    Location
    Missouri
    Posts
    380
    Thanks
    38
    Thanked 45 Times in 43 Posts
    Hi,

    Actually all the info you need is there.

    The HTML to insert into your page is:
    Code:
    <form name="phpformmailer" action="contact_process.php" align="center" method="post">
      <div align="center"><center><table bgcolor="#F2F2F2" width="742" cellspacing="6">
        <tr>
          <td width="162"><strong>Contact Us</strong></td>
          <td width="556"><span class="style3">Protected by: <a
          href="http://thedemosite.co.uk/phpformmailer/">phpFormMailer</a> the freely available PHP form mailer</span></td>
        </tr>
        <tr>
          <td align="right" width="162"><small>Your name:</small></td>
          <td width="556"><font face="Arial"><input class="inputc" size="50" name="name">
          </font></td>
        </tr>
        <tr>
          <td align="right" width="162"><font color="#000080" size="1">*</font><small> Your email
          address:</small></td>
          <td align="left" width="556"><font face="Arial"><input class="inputc" size="50"
          name="email">
          </font></td>
        </tr>
        <tr align="middle">
          <td align="right" width="162"><font color="#000080" size="1">*</font><small> Confirm email
          address:</small></td>
          <td width="556" align="left"><font face="Arial"><input class="inputc" size="50"
          name="email2">
          </font></td>
        </tr>
        <tr>
          <td align="right" width="162"><font color="#000080" size="1">*</font><small> Subject:</small></td>
          <td width="556"><font face="Arial"><input class="inputc" size="60" name="thesubject">
          </font></td>
        </tr>
        <tr>
          <td align="right" width="162">&nbsp;
            <p><font color="#000080" size="1">*</font><small> Your
          request or query:</small></td>
          <td width="556"><textarea style="FONT-SIZE: 10pt" name="themessage" rows="7" cols="60"></textarea></td>
        </tr>
        <tr>
          <td width="162"></td>
          <td width="556"><p>
            <input type="button" class="button"
          value="Send" name="B1" ONCLICK="javascript:validateForm()">
              <small> <small>You must fill in
            the fields marked with a *</p>
            </td>
        </tr>
      </table>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p><span class="style3">Protected by: <a
          href="http://thedemosite.co.uk/phpformmailer/">phpFormMailer</a> the freely available PHP form mailer</span></p>
      </center></div>
    </form>
    
    <script language="JavaScript"><!--
    function validateForm() 
    {
     var okSoFar=true
     with (document.phpformmailer)
     {
      var foundAt = email.value.indexOf("@",0)
      if (foundAt < 1 && okSoFar)
      {
        okSoFar = false
        alert ("Please enter a valid email address.")
        email.focus()
      }
      var e1 = email.value
      var e2 = email2.value
      if (!(e1==e2) && okSoFar)
      {
        okSoFar = false
        alert ("Email addresses you entered do not match.  Please re-enter.")
        email.focus()
      }
      if (thesubject.value=="" && okSoFar)
      {
        okSoFar=false
        alert("Please enter the subject.")
        thesubject.focus()
      }
      if (themessage.value=="" && okSoFar)
      {
        okSoFar=false
        alert("Please enter the details for your enquiry.")
        themessage.focus()
      }
      if (okSoFar==true)  submit();
     }
    }
    // --></script>
    (dont forget the CSS above in the head tags too!)

    Then take the php code, insert it into a blank document named:
    Code:
    contact_process.php
    and upload it to the same location as the contact page.
    Now change the variables where it tells you to:
    Code:
    // ------- three variables you MUST change below  -------------------------------------------------------
    $replyemail="YOU@Your--domain";//change to your email address
    $valid_ref1="http://Your--domain/contact.html";// chamge "Your--domain" to your domain
    $valid_ref2="http://www.Your--domain/contact.html";// chamge "Your--domain" to your domain
    // -------- No changes required below here -------------------------------------------------------------
    // email variable not set - load $valid_ref1 page
    Regards,

    Drew

    Edit-I havent really looked at the code much, but there are probably much better form scripts out there that dont rely on tables so heavily.
    Dev-Tips.com || Employee at the Envato Network || My Portfolio

  • Users who have thanked FWDrew for this post:

    thecodemeist3r (06-18-2008)

  • #7
    New Coder
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Hey thanks for your reply, Ill go through it and see how I go.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •