Jump to content

[SOLVED] Help with HTML Emailer


denoteone

Recommended Posts

I am collecting data from a form and then sending it in an HTLM email. I have all that working.

 

What I want to do is give the user a chance to view the HTML email and go back to make changes or click submit and then the mail function will be called.

I have the go back button working onClick="history.go(-1). this is in the html that is echoed to the user so they can see what is being sent.  But as of right now as soon as the PHP loads it sends the Mail function. I need for it to wait until the user clicks send in the html that is echoed before it calls the mail function.

 

Any help would be awesome.

 

Thanks everyone

 

 

 

Link to comment
Share on other sites

<?

 

    $to = $_POST['guestemail'];

    $from = $_POST['usersemail'];

    $name = $_POST['guestname'];

$sendername = $_POST['usersname'];

$message = $_POST['themessage'];

$subject = "$name Please join us at the next FX";

 

 

$emailmessage = <<<EOF

<html>

  <body bgcolor="#003366">

 

<table align="center" border="1" bordercolor="gray" width="400">

    <tr>

      <td align="center">

        <img src="http://www.bloomingcanvas.com/mike/title.gif"/><br/>

      </td>

    </tr>

   

    <tr>

      <td>

        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt">Dear, $name</font><br/><br/>

        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=12pt"> $message </font> <br/><br/>

        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt"> Regards, <br/> $sendername </font><br/><br/>

        <img src="http://www.bloomingcanvas.com/mike/map.jpg"/><br/><br/>

        <a href="http://www.mapquest.com/maps/map.adp?address=7689%20Bethany%20Rd&city=Liberty%20Township&state=OH&zipcode=45044%2d9515&country=US&title=%3cb%20class%3d%22fn%20org%22%3e7689%20Bethany%20Rd%3c%2fb%3e%3cbr%20%2f%3e%20%3cspan%20style%3d%22display%3ainline%3bmargin%2dbottom%3a0px%3b%22%20class%3d%22locality%22%3eLiberty%20Township%3c%2fspan%3e%2c%20%3cspan%20style%3d%22display%3ainline%3bmargin%2dbottom%3a0px%3b%22%20class%3d%22region%22%3eOH%3c%2fspan%3e%20%3cspan%20style%3d%22display%3ainline%3bmargin%2dbottom%3a0px%3b%22%20class%3d%22postal%2dcode%22%3e45044%2d9515%3c%2fspan%3e%2c%20%20%3cspan%20style%3d%22display%3ainline%3bmargin%2dbottom%3a0px%3b%22%20class%3d%22country%2dname%22%3eUS%3c%2fspan%3e%3c%2fspan%3e&cid=lfmaplink2&name=&dtype=s">Map of 7689 Bethany Rd Liberty Township, OH 45044-9515,  US</a>

      </td>

    </tr>

</table>

</body>

</html>

EOF;

 

 

$success_sent_msg = <<<EOF

<html>

  <body bgcolor="#003366">

 

<table align="center" border="1" bordercolor="gray" width="400">

    <tr>

      <td align="center">

        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt">The message below has been sent to the Email you provided.</font>

        <img src="http://www.bloomingcanvas.com/mike/title.gif"/><br/>

      </td>

    </tr>

   

    <tr>

      <td>

        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt">Dear, $name</font><br/><br/>

        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=12pt"> $message </font> <br/><br/>

        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt"> Regards, <br/> $sendername </font><br/><br/>

        <img src="http://www.bloomingcanvas.com/mike/map.jpg"/><br/><br/>

        <a href="http://www.mapquest.com/maps/map.adp?address=7689%20Bethany%20Rd&city=Liberty%20Township&state=OH&zipcode=45044%2d9515&country=US&title=%3cb%20class%3d%22fn%20org%22%3e7689%20Bethany%20Rd%3c%2fb%3e%3cbr%20%2f%3e%20%3cspan%20style%3d%22display%3ainline%3bmargin%2dbottom%3a0px%3b%22%20class%3d%22locality%22%3eLiberty%20Township%3c%2fspan%3e%2c%20%3cspan%20style%3d%22display%3ainline%3bmargin%2dbottom%3a0px%3b%22%20class%3d%22region%22%3eOH%3c%2fspan%3e%20%3cspan%20style%3d%22display%3ainline%3bmargin%2dbottom%3a0px%3b%22%20class%3d%22postal%2dcode%22%3e45044%2d9515%3c%2fspan%3e%2c%20%20%3cspan%20style%3d%22display%3ainline%3bmargin%2dbottom%3a0px%3b%22%20class%3d%22country%2dname%22%3eUS%3c%2fspan%3e%3c%2fspan%3e&cid=lfmaplink2&name=&dtype=s">Map of 7689 Bethany Rd Liberty Township, OH 45044-9515,  US</a>

      </td>

    </tr>

<tr>

<td><a href="#" onClick="history.go(-1)">Click Here</a><Font>to make changes</Font>

</td>

<td>******* I NEED THE SEND BUTTON HERE******************</p>

</td>

</tr>

</table>

</body>

</html>

EOF;

 

  echo $success_sent_msg;

 

    $headers  = "From: $from\r\n";

    $headers .= "Content-type: text/html\r\n";

    $to = "$to, $from"; // this will send to both emails at the same time.

    // now lets send the email.

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

 

 

 

?>

Link to comment
Share on other sites

<?
   
    $to = $_POST['guestemail'];
    $from = $_POST['usersemail'];
    $name = $_POST['guestname'];
   $sendername = $_POST['usersname'];
   $message = $_POST['themessage'];
   $subject = "$name Please join us at the next FX";


$emailmessage = <<<EOF
<html>
  <body bgcolor="#003366">

<table align="center" border="1" bordercolor="gray" width="400">
    <tr>
       <td align="center">
       

       </td>
    </tr>
   
    <tr>
       <td>
        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt">Dear, $name</font>


        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=12pt"> $message </font>


        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt"> Regards,
$sendername </font>


       


        Map of 7689 Bethany Rd Liberty Township, OH 45044-9515,  US
       </td>
    </tr>
</table>
</body>
</html>
EOF;


$success_sent_msg = <<<EOF
<html>
  <body bgcolor="#003366">

<table align="center" border="1" bordercolor="gray" width="400">
    <tr>
       <td align="center">
        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt">The message below has been sent to the Email you provided.</font>
       

       </td>
    </tr>
   
    <tr>
       <td>
        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt">Dear, $name</font>


        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=12pt"> $message </font>


        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt"> Regards,
$sendername </font>


       


        Map of 7689 Bethany Rd Liberty Township, OH 45044-9515,  US
       </td>
    </tr>
<tr>
<td><a href="#" onClick="history.go(-1)">Click Here[/url]<Font>to make changes</Font>
</td>
<td><form action="yourphpfilename.php" method="post"><input type="submit" name="sendmail" value="Send Email" /></form></p>
</td>
</tr>
</table>
</body>
</html>
EOF;

   echo $success_sent_msg;

    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";
    $to = "$to, $from"; // this will send to both emails at the same time.
    // now lets send the email.


    if(isset($_POST["sendmail"])) mail($to, $subject, $emailmessage, $headers);



?>

 

Try that. Remember to replace yourphpfilename.php with your actual filename.

Link to comment
Share on other sites

<?php
   
    $to = $_POST['guestemail'];
    $from = $_POST['usersemail'];
    $name = $_POST['guestname'];
   $sendername = $_POST['usersname'];
   $message = $_POST['themessage'];
   $subject = "$name Please join us at the next FX";


$emailmessage = <<<EOF
<html>
  <body bgcolor="#003366">

<table align="center" border="1" bordercolor="gray" width="400">
    <tr>
       <td align="center">
       

       </td>
    </tr>
   
    <tr>
       <td>
        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt">Dear, $name</font>


        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=12pt"> $message </font>


        <font style="font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt"> Regards,
$sendername </font>


       


        Map of 7689 Bethany Rd Liberty Township, OH 45044-9515,  US
       </td>
    </tr>
</table>
</body>
</html>
EOF;


$success_sent_msg = "<html>
  <body bgcolor=\"#003366\">

<table align=\"center\" border=\"1\" bordercolor=\"gray\" width=\"400\">
    <tr>
       <td align=\"center\">
        <font style=\"font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt\">The message below has been sent to the Email you provided.</font>
       

       </td>
    </tr>
   
    <tr>
       <td>
        <font style=\"font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt\">Dear, $name</font>


        <font style=\"font-family:verdana,arial,helvetica; font-color=GRAY; font-size=12pt\"> $message </font>


        <font style=\"font-family:verdana,arial,helvetica; font-color=GRAY; font-size=14pt\"> Regards,
$sendername </font>


       


        Map of 7689 Bethany Rd Liberty Township, OH 45044-9515,  US
       </td>
    </tr>
<tr>
<td><a href=\"#\" onClick=\"history.go(-1)\">Click Here[/url]<Font>to make changes</Font>
</td>
<td><form action=\"yourphpfilename.php\" method=\"post\"><input type=\"hidden\" name=\"guestemail\" value=\"{$to}\" /><input type=\"hidden\" name=\"usersemail\" value=\"{$from}\" /><input type=\"hidden\" name=\"guestname\" value=\"{$name}\" /><input type=\"hidden\" name=\"usersname\" value=\"{$sendername}\" /><input type=\"hidden\" name=\"themessage\" value=\"{$message}\" /><input type=\"submit\" name=\"sendmail\" value=\"Send Email\" /></form></p>
</td>
</tr>
</table>
</body>
</html>";

   echo $success_sent_msg;

    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";
    $to = "$to, $from"; // this will send to both emails at the same time.
    // now lets send the email.


    if(isset($_POST["sendmail"])) mail($to, $subject, $emailmessage, $headers);



?>

 

Try that..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.