Menu

Send HTML email to user who filled out form

Help
Susan
2008-04-14
2013-06-03
  • Susan

    Susan - 2008-04-14

    I would like to send an HTML email to the user who filled out the form, and send an email to the administrator of the form. Instead of going to the person who requested the form, however, the email is going to "field_2@" on my secure server. "field_2" is the Email field on my form, but I want the data entered into that field to be used for the email address; not the field name. What am I doing wrong?

    Here is the form:
    http://www.speedwayinstruments.com/forms/dealer_registration_form.html

    Here is the processor.php:

    <?php

    $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
    $dtstamp=date("m.d.Y, H:i:s");

    // multiple recipients
    $to  = 'susanbednar@gmail.com' . ', '; // note the comma
    $to .= 'susanbednar@yahoo.com' . ', '; // note the comma
    $to .= $form_variable_email;

    // subject
    $subject = 'Dealer Application Process';

    // message
    $message = '
    <html>
    <head>
      <title>Speedway Instruments Dealer Application - Form Submission</title>
    </head>
    <body>
        <p><a href="http://www.speedwayinstruments.com"><img src="http://www.speedwayinstruments.com/images/speedway.gif" border="0"></a><p>
        <p>&nbsp;</p>
        <p><strong>Dear Future Speedway Instruments Dealer:</strong></p>
        <p>Thank you for your interest in becoming a dealer for Speedway Instruments products! We hope that you find our dealer support to be fanatical. We think that we have something that is pretty special &mdash; and we want you to be a part of our story. You have found the creator of the smallest tachometer for the V-Twin market. Because you have better things to do than paperwork all day, we have made becoming an authorized Speedway Instruments simple.</p>
        <p><strong>Step 1:&nbsp;&nbsp;</strong>Complete the dealer application</a> (PDF).</p>
        <p><strong>Step 2:&nbsp;&nbsp;</strong>Mail inside and outside photos of your business, photocopy of credit card (front and back) along with a photocopy of your state business license.</p>
        <p><strong>Step 3:&nbsp;&nbsp;</strong>Return all required information to Speedway Instruments. Speedway Instruments personnel can assist you throughout the entire dealer application process. If you have any questions, just call. Everyone at Speedway Instruments is genuinely committed to serving our customers.</p>
    <p><strong>That&rsquo;s it; then you&rsquo;re done!</strong> We will call you quickly with approval status.</p>
        <p>Upon approval, you will receive dealer pricing and order forms. Speedway Instruments staff will call to explain how you place your first order and answer any questions you may have about the product. We are always available to provide detailed information about our entire product line. </p>
        <p>Again, thank you for choosing Speedway Instruments as a partner for your aftermarket business. We appreciate the support and will do our very best to provide you fantastic customer service and guarantee you will receive the highest-quality instruments available today that will set your bikes apart!</p>
        <p>Sincerely,<br />
        Speedway Instruments</p>
        <p>&nbsp;</p>
    </body>
    </html>
    ';

    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    // Additional headers
    $headers .= 'From: Speedway Instruments <info@speedwayinstruments.com>' . "\r\n" .
        'Reply-To: info@speedwayinstruments.com' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();

    mail($to,$subject,$message,$headers);

    $fileLine = "" . $_POST['field_1'] . ", " . $_POST['field_2'] . ", " . $_POST['field_3'] . ", " . $_POST['field_4'] . ", " . $_POST['field_5'] . ", " . $dtstamp . "
    ";

    $filename = 'dealers.txt';
    if (is_writable($filename)) {

                    if (!$handle = fopen($filename, 'a'))
                    {
                         echo "Cannot open file ($filename)";
                         exit;
                    }
                    if (fwrite($handle, $fileLine) === FALSE) {
                        echo "Cannot write to file ($filename)";
                        exit;
                    }

                    fclose($handle);

                } else {
                    echo "The file  is not writable";
                }

    include("confirm.html");

    ?>

     
    • TNTEverett

      TNTEverett - 2008-04-14

      I am not entirely sure what you are asking for here.  If you are leaving out detail you don't want to appear in the forum, send me an email message. 
      From your processor.php code it is clear you are sending HTML to multiple recipients. 
      You nned to be perfectly clear as to what you want to send (content and type of email) to each specific address and how the address is captured (form field or coded into processor.php).

       
    • Susan

      Susan - 2008-04-16

      TNTEverett,

      I sent you an email with more details about the form. Were you able to look at it? Any ideas?

      Thank you!
      Susan

       
      • TNTEverett

        TNTEverett - 2008-04-16

        Sent you a reply twice now.  Are you still not getting it?  I did not want to include my responses here because I don't want you to continue to expose your private information (emails and URLs) in this forum. 

         
        • Susan

          Susan - 2008-04-16

          Yes, I got it, and it works. Thank you very much!!!

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.