GrizzlyBear Posted July 4, 2008 Share Posted July 4, 2008 Hi I have attached an image of what I want to do below. Basically I have created a form and executing the form using PHP coding. But I need help in being able to specify the format the content inserted into the form will be display in the received email. Thanks PS: Here is the html form coding for the above mailer... <td width="300" class="style1"> <input class="formstyle1" id="name2" maxlength="50" size="40" name="Name" /> </td> </tr> <tr> <td width="200" class="style1"> </td> <td width="300" class="style1"> </td> </tr> <tr> <td width="200" height="20" class="style1"><strong>Surname</strong></td> <td width="300" class="style1"> <input class="formstyle1" id="surname2" maxlength="11" size="40" name="Surname" /> </td> </tr> <tr> <td width="200" class="style1"> </td> <td width="300" class="style1"> </td> </tr> <tr> <td width="200" height="20" class="style1"><strong>Telephone</strong></td> <td width="300" class="style1"> <input class="formstyle1" id="telephone2" maxlength="50" size="40" name="Telephone" /> </td> </tr> <tr> <td width="200" class="style1"> </td> <td width="300" class="style1"> </td> </tr> <tr> <td width="200" height="20" class="style1"><strong>E-mail</strong></td> <td width="300" class="style1"> <input class="formstyle1" id="email2" maxlength="50" size="40" name="Email" /> </td> </tr> <tr> <td width="200" class="style1"> </td> <td width="300" class="style1"> </td> </tr> <tr> <td width="200" height="20" class="style1"><strong>Enquiry</strong></td> <td width="300" class="style1"> <label> <textarea name="Enquiry" cols="41" rows="5" class="style1" id="enquiry2"></textarea> </label> </td> [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/113204-solved-displaying-content-in-a-table-format-when-mailed-from-a-html-form-using-php-code/ Share on other sites More sharing options...
Wolphie Posted July 4, 2008 Share Posted July 4, 2008 This isn't a failsafe method. A lot of people have HTML formatting switched off for their e-mails, in which case if you were to send a HTML formatted e-mail they would get thoroughly confused. You should provide an option for your users to select which format the e-mail should be in. And in which case, if they make a mistake it's down to them. And you'll then be able to determine which format the e-mail should be sent in, either plain text or HTML. But back to your original question: <?php $to = 'example@domain.com'; $message = '<html><head><title>HTML E-mail!</title></head><body>This is an HTML e-mail!</body></html>'; $subject = 'HTML E-mail!'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: anotherexample@domain.com'; mail($to, $subject, $message, $headers); ?> Quote Link to comment https://forums.phpfreaks.com/topic/113204-solved-displaying-content-in-a-table-format-when-mailed-from-a-html-form-using-php-code/#findComment-581603 Share on other sites More sharing options...
GrizzlyBear Posted July 4, 2008 Author Share Posted July 4, 2008 Thanks Wolphie, that was exactly what i was looking for. I just have one more q... how do i get the $info command to work in table in the script below? thanks hey.. <?php $to = 'test@domain.co.za'; $email = $_REQUEST['email']; $info = $_REQUEST['message']; $message = ' <html> <head> <title>HTML E-mail!</title> </head> <body> <table border="1"> <tr> <td>$info</td> <td>This is an HTML e-mail!</td> <td>This is an HTML e-mail!</td> </tr> </table> </body> </html>'; $subject = 'HTML E-mail!'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: $email'; mail($to, $subject, $message, $headers); ?> Quote Link to comment https://forums.phpfreaks.com/topic/113204-solved-displaying-content-in-a-table-format-when-mailed-from-a-html-form-using-php-code/#findComment-581627 Share on other sites More sharing options...
Wolphie Posted July 4, 2008 Share Posted July 4, 2008 <?php $to = 'test@domain.co.za'; $email = $_POST['email']; $info = $_POST['message']; // this should be the same as the name on the form element $message = <<<MESSAGE <html> <head> <title>HTML E-mail!</title> </head> <body> <table border="1"> <tr> <td>$info</td> <td>This is an HTML e-mail!</td> <td>This is an HTML e-mail!</td> </tr> </table> </body> </html> MESSAGE; $subject = 'HTML E-mail!'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: ' . $email; mail($to, $subject, $message, $headers); ?> Quote Link to comment https://forums.phpfreaks.com/topic/113204-solved-displaying-content-in-a-table-format-when-mailed-from-a-html-form-using-php-code/#findComment-581653 Share on other sites More sharing options...
GrizzlyBear Posted July 4, 2008 Author Share Posted July 4, 2008 Thanks Wolphie...I appreciate the help Quote Link to comment https://forums.phpfreaks.com/topic/113204-solved-displaying-content-in-a-table-format-when-mailed-from-a-html-form-using-php-code/#findComment-581656 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.