nate51 Posted January 10, 2008 Share Posted January 10, 2008 I'm new to this forum and semi new to php. I am in need of help badly here as I have a deadline going. I have a registry page (html) with fields for name, number, address etc. The way I used to do php reg forms was to have a first page with fill in boxes (fields) after filling in clicking submit would link to a second page thanking people for registering... An email would go to a specified email address displaying the information entered into the fields. Really basic script really simple but affective. I now need to make an html email so that the field information is sent to a specific email address with html code around it to present the information to look more like a fill out card with a logo on the top right, then the basic simple text style. I have been looking for awhile and am coming up dry for answers. Most of the tutorials I find don't detail how to make the field information display in the html email. Can anyone help me? Or point me in the right direction? -- Nathan Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/ Share on other sites More sharing options...
drummer101 Posted January 10, 2008 Share Posted January 10, 2008 So wait, what you want is to send the registration page to them? Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-435947 Share on other sites More sharing options...
revraz Posted January 10, 2008 Share Posted January 10, 2008 He wants to send them a HTML formatted email Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-435948 Share on other sites More sharing options...
The Little Guy Posted January 10, 2008 Share Posted January 10, 2008 Go here: http://us.php.net/manual/en/function.mail.php scroll down to Example #4 Note: The headers are the most important Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-435954 Share on other sites More sharing options...
nate51 Posted January 10, 2008 Author Share Posted January 10, 2008 He wants to send them a HTML formatted email Bingo! The way I know of and am used to is someone goes to a page fills out the form hits send and they see a "Thank you" page. Now someone on another end recieves an email with all their information to do what they please with it, i.e. enter into a data base, add to a mailing list etc. But I need to change the way it arrives to the recipient. I need to change it from plain text to html. Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-435957 Share on other sites More sharing options...
revraz Posted January 10, 2008 Share Posted January 10, 2008 Just know that quite a few people don't accept html email, like me. Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-435960 Share on other sites More sharing options...
drummer101 Posted January 10, 2008 Share Posted January 10, 2008 He wants to send them a HTML formatted email This part threw me off.. I now need to make an html email so that the field information is sent ... to present the information to look more like a fill out card with a logo on the top right, then the basic simple text style. Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-435962 Share on other sites More sharing options...
drummer101 Posted January 10, 2008 Share Posted January 10, 2008 Just know that quite a few people don't accept html email, like me. Ah I get it now, he doesn't want to send the HTML mail to the end user, he wants to send it to someone else.. an admin or mod persay Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-435965 Share on other sites More sharing options...
nate51 Posted January 10, 2008 Author Share Posted January 10, 2008 Go here: http://us.php.net/manual/en/function.mail.php scroll down to Example #4 Note: The headers are the most important I tried this one earlier and it did help me a bit, I now get html code to my email but lines like this... <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Full Name:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$firstname \n</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$midname \n</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$lastname \n</td> I know this is wrong because instead of getting the persons information it comes just as you see it "$firstname" etc. I need to know how to make that call up the information entered into the fields. Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-435975 Share on other sites More sharing options...
revraz Posted January 10, 2008 Share Posted January 10, 2008 $variables need to be in " " double quotes Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-435976 Share on other sites More sharing options...
nate51 Posted January 10, 2008 Author Share Posted January 10, 2008 Ok, The email now comes to my email address looking the way I want except for 2 issues remaining. 1. The logo I need on the right hand side is not showing even though I have allowed that email address to accept images and it is an absolute link. 2. The fields are still coming to my email like this $lastname \n. I have tried adding "" to them i.e. "$lastname \n" also like this "$lastname" and both ways don't bring the data in right. btw thanks to all the replies from everyone so far. Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-435998 Share on other sites More sharing options...
revraz Posted January 10, 2008 Share Posted January 10, 2008 Post the code, it will be easier. Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-436005 Share on other sites More sharing options...
nate51 Posted January 10, 2008 Author Share Posted January 10, 2008 <?php // multiple recipients $to = 'xxxx@xxxx.com'; // subject $subject = 'e-Card'; // message $message = ' <html> <body bgcolor="#ffffff"> <div align=center><table border=0 cellspacing=0 cellpadding=1 bgcolor=#555555><tr><td><table border=0 cellspacing=0 cellpadding=5><tr><td class=title colspan=5 valign=middle nowrap bgcolor=#ffffff> <blockquote>Enrollment Card for xxxxxx</blockquote> </td><td align=right valign=middle nowrap bgcolor=#ffffff> <img src="http://www.xxxxxx.com/xxx/images/mail_logo.jpg" alt="[Logo]" border=0></td> </tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Full Name:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>"$firstname"</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>"$midname"</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>"$lastname"</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Date of Birth:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>"$dob"</td> </tr><tr> <td class=label align=left valign=middle nowrap bgcolor=white> </td> <td class=footer align=left valign=middle nowrap bgcolor=white>Last</td> <td class=footer align=left valign=middle nowrap bgcolor=white>Middle</td> <td class=footer align=left valign=middle nowrap bgcolor=white>First</td> <td class=content align=left valign=middle nowrap bgcolor=white> </td> <td class=content align=left valign=middle nowrap bgcolor=white> </td></tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Address:</td> <td class=content colspan=3 align=left valign=middle nowrap bgcolor=#eeeeee>"$address"</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>City:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>"$city"</td> </tr><tr> <td class=label colspan=6 align=left valign=middle nowrap bgcolor=white> </td></tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Province:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>"$province"</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Postal Code:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>"$postalcode"</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Kit Requested: </td> <td colspan=2 align=left valign=middle nowrap bgcolor=#eeeeee class=content>"$choice"</td> </tr><tr> <td class=label colspan=6 align=left valign=middle nowrap bgcolor=white> </td></tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Telephone:</td> <td class=content colspan=2 align=left valign=middle nowrap bgcolor=#eeeeee>"$phone"</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Mobile Phone: </td> <td colspan=2 align=left valign=middle bgcolor=#eeeeee class=content>"$cell"</td> </tr><tr> <td class=label colspan=6 align=left valign=middle nowrap bgcolor=white> </td></tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Beneficiary:</td> <td class=content colspan=2 align=left valign=middle nowrap bgcolor=#eeeeee>"$beneficiary"</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Relationship:</td> <td class=content colspan=2 align=left valign=middle bgcolor=#eeeeee>"$relation"</td> <tr> <td class=label colspan=6 align=right valign=middle nowrap bgcolor=#eeeeee>SGC3O</td> </tr></table></td></tr></table> </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"; // Mail it mail($to, $subject, $message, $headers); ?> This php is in the Thank You page. Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-436010 Share on other sites More sharing options...
revraz Posted January 10, 2008 Share Posted January 10, 2008 Double quote the string that the variable is in. In regards to the logo, can't help you there, but it may be better as an attachment. $message = " <html> <body bgcolor='#ffffff'> <div align=center><table border=0 cellspacing=0 cellpadding=1 bgcolor=#555555><tr><td><table border=0 cellspacing=0 cellpadding=5><tr><td class=title colspan=5 valign=middle nowrap bgcolor=#ffffff> <blockquote>Enrollment Card for xxxxxx</blockquote> </td><td align=right valign=middle nowrap bgcolor=#ffffff> <img src='http://www.xxxxxx.com/xxx/images/mail_logo.jpg' alt='[Logo]' border=0></td> </tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Full Name:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$firstname</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$midname</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$lastname</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Date of Birth:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$dob</td> </tr><tr> <td class=label align=left valign=middle nowrap bgcolor=white> </td> <td class=footer align=left valign=middle nowrap bgcolor=white>Last</td> <td class=footer align=left valign=middle nowrap bgcolor=white>Middle</td> <td class=footer align=left valign=middle nowrap bgcolor=white>First</td> <td class=content align=left valign=middle nowrap bgcolor=white> </td> <td class=content align=left valign=middle nowrap bgcolor=white> </td></tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Address:</td> <td class=content colspan=3 align=left valign=middle nowrap bgcolor=#eeeeee>$address</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>City:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$city</td> </tr><tr> <td class=label colspan=6 align=left valign=middle nowrap bgcolor=white> </td></tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Province:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$province</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Postal Code:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$postalcode</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Kit Requested: </td> <td colspan=2 align=left valign=middle nowrap bgcolor=#eeeeee class=content>$choice</td> </tr><tr> <td class=label colspan=6 align=left valign=middle nowrap bgcolor=white> </td></tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Telephone:</td> <td class=content colspan=2 align=left valign=middle nowrap bgcolor=#eeeeee>$phone</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Mobile Phone: </td> <td colspan=2 align=left valign=middle bgcolor=#eeeeee class=content>$cell</td> </tr><tr> <td class=label colspan=6 align=left valign=middle nowrap bgcolor=white> </td></tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Beneficiary:</td> <td class=content colspan=2 align=left valign=middle nowrap bgcolor=#eeeeee>$beneficiary</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Relationship:</td> <td class=content colspan=2 align=left valign=middle bgcolor=#eeeeee>$relation</td> <tr> <td class=label colspan=6 align=right valign=middle nowrap bgcolor=#eeeeee>SGC3O</td> </tr></table></td></tr></table> </body> </html>"; Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-436015 Share on other sites More sharing options...
nate51 Posted January 10, 2008 Author Share Posted January 10, 2008 Double quotes didn't change anything. I don't know if this helps or not but the php code I gave is in a php page that has html code to display images and text for the Thank You page. Full page code. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> <!-- body { background-image: url(images/bg.jpg); background-position:Center; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } .textbox { BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #333333 1px solid; FONT-SIZE: 11px; BACKGROUND-IMAGE: url(images/field_bg.gif); BORDER-LEFT: #333333 1px solid; COLOR: #2e415f; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; HEIGHT: 17px; BACKGROUND-COLOR: #f0eddc } .style9 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; } .style10 { font-size: 16px } .style11 {font-size: 18px} .style12 {font-family: Arial, Helvetica, sans-serif} .style13 { color: #0168B3; font-weight: bold; } --> </style> <script type="text/javascript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <body onload="MM_preloadImages('images/nav/intro_btno.jpg','images/nav/group_btno.jpg','images/nav/reply_btno.jpg')"> <?php // multiple recipients $to = 'xxxx@xxxx.com'; // subject $subject = 'e_Card'; // message $message = " <html> <body bgcolor="#ffffff"> <div align=center><table border=0 cellspacing=0 cellpadding=1 bgcolor=#555555><tr><td><table border=0 cellspacing=0 cellpadding=5><tr><td class=title colspan=5 valign=middle nowrap bgcolor=#ffffff> <blockquote>Enrollment Card for OACCPP</blockquote> </td><td align=right valign=middle nowrap bgcolor=#ffffff> <img src="http://www.xxxxxx.com/xxx/images/mail_logo.jpg" alt="[Logo]" border=0></td> </tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Full Name:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$firstname</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$midname</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$lastname</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Date of Birth:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$dob</td> </tr><tr> <td class=label align=left valign=middle nowrap bgcolor=white> </td> <td class=footer align=left valign=middle nowrap bgcolor=white>Last</td> <td class=footer align=left valign=middle nowrap bgcolor=white>Middle</td> <td class=footer align=left valign=middle nowrap bgcolor=white>First</td> <td class=content align=left valign=middle nowrap bgcolor=white> </td> <td class=content align=left valign=middle nowrap bgcolor=white> </td></tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Address:</td> <td class=content colspan=3 align=left valign=middle nowrap bgcolor=#eeeeee>$address</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>City:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$city</td> </tr><tr> <td class=label colspan=6 align=left valign=middle nowrap bgcolor=white> </td></tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Province:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$province</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Postal Code:</td> <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>$postalcode</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Kis Kit Requested: </td> <td colspan=2 align=left valign=middle nowrap bgcolor=#eeeeee class=content>$choice</td> </tr><tr> <td class=label colspan=6 align=left valign=middle nowrap bgcolor=white> </td></tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Telephone:</td> <td class=content colspan=2 align=left valign=middle nowrap bgcolor=#eeeeee>$phone</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Mobile Phone: </td> <td colspan=2 align=left valign=middle bgcolor=#eeeeee class=content>$cell</td> </tr><tr> <td class=label colspan=6 align=left valign=middle nowrap bgcolor=white> </td></tr><tr> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Beneficiary:</td> <td class=content colspan=2 align=left valign=middle nowrap bgcolor=#eeeeee>$beneficiary</td> <td class=label align=right valign=middle nowrap bgcolor=#eeeeee>Relationship:</td> <td class=content colspan=2 align=left valign=middle bgcolor=#eeeeee>$relation</td> <tr> <td class=label colspan=6 align=right valign=middle nowrap bgcolor=#eeeeee>SGC3O</td> </tr></table></td></tr></table> </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"; // Mail it mail($to, $subject, $message, $headers); ?> <table width="752" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="724"> </td> </tr> <tr> <td><div align="center"><img src="images/iaomaaw_logo.jpg" width="700" height="113" /></div></td> </tr> <tr> <td> </td> </tr> <tr> <td bgcolor="#D9D9D9"><table width="75" border="0" cellpadding="0" cellspacing="0"> <tr> <td><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('intro','','images/nav/intro_btno.jpg',1)"><img src="images/nav/intro_btn.jpg" name="intro" width="129" height="24" border="0" id="intro" /></a></td> <td><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('group','','images/nav/group_btno.jpg',1)"><img src="images/nav/group_btn.jpg" name="group" width="140" height="24" border="0" id="group" /></a></td> <td><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('reply','','images/nav/reply_btno.jpg',1)"><img src="images/nav/reply_btn.jpg" name="reply" width="131" height="24" border="0" id="reply" /></a></td> </tr> </table></td> </tr> <tr> <td><table width="308" border="0" cellpadding="0" cellspacing="4"> <tr> <td width="14" class="style9 style10"> </td> <td width="282" height="30" class="style9 style10"><span class="style13">Replay Card</span><br /></td> </tr> </table></td> </tr> <tr> <td><table width="357" border="0" align="center" cellpadding="0" cellspacing="8"> <tr> <td width="341" class="style11 style12">Thank you for registering for a Kit</td> </tr> </table></td> </tr> <tr> <td> </td> </tr> <tr> <td height="50" bgcolor="#E2E2E2"><p align="center" class="style9">Contents Copyright © xxxxxxxx. All rights reserved.<br /> For more information, please contact us at <a href="mailto:xxx@xxxxxx.com">xxx@xxxxxx.com</a>.</p></td> </tr> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-436026 Share on other sites More sharing options...
drummer101 Posted January 10, 2008 Share Posted January 10, 2008 Edit: nevermind, didn't read the entire posted source. :-\ Edit2: try.. <td class=content colspan=2 align=left valign=middle bgcolor=#eeeeee>' . $relation . '</td> Edit3: \/\/ Yeah that'd work too. Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-436029 Share on other sites More sharing options...
revraz Posted January 10, 2008 Share Posted January 10, 2008 You didnt copy and paste what I entered, there are double quotes in the string you have to make single quotes. Just copy/paste what I did over yours. Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-436036 Share on other sites More sharing options...
nate51 Posted January 10, 2008 Author Share Posted January 10, 2008 Edit: nevermind, didn't read the entire posted source. :-\ Edit2: try.. <td class=content colspan=2 align=left valign=middle bgcolor=#eeeeee>' . $relation . '</td> That did it! Thank you so much for the help! Everything works perfect. Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-436045 Share on other sites More sharing options...
drummer101 Posted January 10, 2008 Share Posted January 10, 2008 No problem, glad to help Quote Link to comment https://forums.phpfreaks.com/topic/85441-php-to-email-resolved/#findComment-436074 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.