denoteone Posted December 21, 2007 Share Posted December 21, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/82675-solved-help-with-html-emailer/ Share on other sites More sharing options...
chigley Posted December 21, 2007 Share Posted December 21, 2007 Perhaps show us your code? Quote Link to comment https://forums.phpfreaks.com/topic/82675-solved-help-with-html-emailer/#findComment-420485 Share on other sites More sharing options...
denoteone Posted December 21, 2007 Author Share Posted December 21, 2007 <? $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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/82675-solved-help-with-html-emailer/#findComment-420494 Share on other sites More sharing options...
chigley Posted December 21, 2007 Share Posted December 21, 2007 <? $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. Quote Link to comment https://forums.phpfreaks.com/topic/82675-solved-help-with-html-emailer/#findComment-420497 Share on other sites More sharing options...
denoteone Posted December 21, 2007 Author Share Posted December 21, 2007 I got an error message when I clicked the send email button. " No recipient addresses found in header" I did not get emails in either acount sender or recipient. Quote Link to comment https://forums.phpfreaks.com/topic/82675-solved-help-with-html-emailer/#findComment-420510 Share on other sites More sharing options...
chigley Posted December 21, 2007 Share Posted December 21, 2007 OK you need to put a hidden field in the form I made, for all of the values which are received from the previous page. Quote Link to comment https://forums.phpfreaks.com/topic/82675-solved-help-with-html-emailer/#findComment-420514 Share on other sites More sharing options...
denoteone Posted December 21, 2007 Author Share Posted December 21, 2007 I am a newbie at this how would i set the empty field with those varialbles? Quote Link to comment https://forums.phpfreaks.com/topic/82675-solved-help-with-html-emailer/#findComment-420521 Share on other sites More sharing options...
chigley Posted December 21, 2007 Share Posted December 21, 2007 <?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.. Quote Link to comment https://forums.phpfreaks.com/topic/82675-solved-help-with-html-emailer/#findComment-420524 Share on other sites More sharing options...
denoteone Posted December 21, 2007 Author Share Posted December 21, 2007 Thank you chigley I got everything working! Quote Link to comment https://forums.phpfreaks.com/topic/82675-solved-help-with-html-emailer/#findComment-420766 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.