Well, I asked this question before, but I did not get a clear answer, and this time I will also explain it better.
I have a contact form which, when it is sent, is sent by e-mail in the form of plain text, which is NOT what I want. I want the view to have at least some style and be neat (using my own HTML below). I tried to get this to work before, but without success, and now you need outside help.
Here is the php process form:
<?php if (!isset($_SESSION)) session_start(); if(!$_POST) exit; if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n"); $address = " email@domain.com "; $bcc = " email@domain.com "; $twitter_active = 0; $twitter_user = ""; $consumer_key = ""; $consumer_secret = ""; $token = ""; $secret = ""; $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $dayin = $_POST['dayin']; $dayout = $_POST['dayout']; $comments = $_POST['comments']; if (isset($_POST['verify'])) : $posted_verify = $_POST['verify']; $posted_verify = md5($posted_verify); else : $posted_verify = ''; endif; // Important Variables $session_verify = $_SESSION['verify']; if (empty($session_verify)) $session_verify = $_COOKIE['verify']; $error = ''; if(trim($name) == '') { $error .= '<li>Your name is required.</li>'; } if(trim($email) == '') { $error .= '<li>Your e-mail address is required.</li>'; } elseif(!isEmail($email)) { $error .= '<li>You have entered an invalid e-mail address.</li>'; } if(trim($phone) == '') { $error .= '<li>Your phone number is required.</li>'; } elseif(!is_numeric($phone)) { $error .= '<li>Your phone number can only contain digits (no spaces).</li>'; } if(trim($comments) == '') { $error .= '<li>You must enter a message to send.</li>'; } if($session_verify != $posted_verify) { $error .= '<li>The verification code you entered is incorrect. </li>'; } if($error != '') { echo '<div class="error_message">Attention! Please correct the errors below and try again.'; echo '<ul class="error_messages">' . $error . '</ul>'; echo '</div>'; } else { if(get_magic_quotes_gpc()) { $comments = stripslashes($comments); } $e_subject = 'Website Enquiry'; $msg = '<html><body> <strong>WEBSITE ENQUIRY FROM:</strong><br> www.domainname.com<br> -----------------------------------------------------------<br><br> <strong>Name: </strong> '.$_POST['name'].' <br> <strong>Email: </strong> '.$_POST['email'].' <br> <strong>Contact Number: </strong> '.$_POST['phone'].' <br> <strong>Day in: </strong> '.$_POST['dayin'].' <br> <strong>Day out: </strong> '.$_POST['dayout'].'<br><br> <strong>Notes / Comments: </strong><br> '.$_POST['comments'].' </body></html>'; if($twitter_active == 1) { $twitter_msg = $name . " - " . $comments . ". You can contact " . $name . " via email, " . $email ." or via phone " . $phone . "."; twittermessage($twitter_user, $twitter_msg, $consumer_key, $consumer_secret, $token, $secret); } $msg = wordwrap( $msg, 70 ); $headers = "From: $email\r\nBCC:{$bcc}\r\n" . PHP_EOL; $headers .= "Reply-To: $email" . PHP_EOL; $headers .= "MIME-Version: 1.0" . PHP_EOL; $headers .= "Content-type: text/html; charset=utf-8" . PHP_EOL; $headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL; if(mail($address, $e_subject, $msg, $headers)) { echo "<fieldset>"; echo "<div id='success_page'>"; echo "<img src='success.png' align='absmiddle' style='padding-right:5px;' /><strong>Email Sent Successfully.</strong>"; echo "</div>"; echo "</fieldset>"; } else { echo 'ERROR!'; // Dont Edit. } } function twittermessage($user, $message, $consumer_key, $consumer_secret, $token, $secret) { // Twitter Direct Message function, do not edit. require_once('twitter/EpiCurl.php'); require_once('twitter/EpiOAuth.php'); require_once('twitter/EpiTwitter.php'); $Twitter = new EpiTwitter($consumer_key, $consumer_secret); $Twitter->setToken($token, $secret); $direct_message = $Twitter->post_direct_messagesNew( array('user' => $user, 'text' => $message) ); $tweet_info = $direct_message->responseText; } ?>
Pay attention to this code in the form above:
$msg = '<html><body> <strong>WEBSITE ENQUIRY FROM:</strong><br> www.domainname.com<br> -----------------------------------------------------------<br><br> <strong>Name: </strong> '.$_POST['name'].' <br> <strong>Email: </strong> '.$_POST['email'].' <br> <strong>Contact Number: </strong> '.$_POST['phone'].' <br> <strong>Day in: </strong> '.$_POST['dayin'].' <br> <strong>Day out: </strong> '.$_POST['dayout'].'<br><br> <strong>Notes / Comments: </strong><br> '.$_POST['comments'].' </body></html>';
I would like to replace this code above (which creates a text letter) with this HTML code STYLED:
<table width="550" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="78" colspan="2" align="center" valign="middle" bgcolor="#F0F5FB"><span style="font-family:Georgia, 'Times New Roman', Times, serif; font-size: 24px; font-style:italic; color:#0099CC; ">WEBSITE ENQUIRY FROM:</span><br /> <span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333333">www.domainname.com</span></td> </tr> <tr> <td width="177" height="166" valign="middle"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#333333; font-weight:bold;">Name:<br /> Country<br /> Contact Number<br /> Email<br /> No. Guests<br /> Day in<br /> Day Out<br /> Comments </span></td> <td width="373" valign="middle"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#333333; font-weight:bold;">'.$_POST['name'].'<br /> '.$_POST['country'].'<br /> '.$_POST['tel'].'<br /> '.$_POST['email'].'<br /> '.$_POST['guests'].'<br /> '.$_POST['day in'].'<br /> '.$_POST['day out'].'<br /> '.$_POST['comments'].'<br /> </span></td> </tr> </table>
Step by step what needs to be done to get this to work. I tried replacing plain text code with my STYLED html and it does not work. What else do I need to do?
Rate your answers!
EDIT
Please check here: This is what the HTML letter should look like: http://www.testing123.co.za/styled.jpg ..... Here's how it works: http://www.testing123.co.za/not -correct.jpg