Form Email Output styling

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gt11990
Forum Newbie
Posts: 3
Joined: Mon Jul 14, 2014 4:19 am

Form Email Output styling

Post by gt11990 »

I have created a html form which i inserted into my webpage and have done a php file to send me the details entered into the from via email however,

i don't receive a email
and

i would like to receive the results with html formatting.
I have looked everywhere to try find a solution but did not find one.

Could someone please help please i am really really stuck.

Thank You

My HTML code

Code: Select all

<form method="post" action="/form/php/sendresults.php">
<label>First Name:  <input type="text" name="firstname" size="30" maxlength="30" />   
   </label>
<label>Last Name:  <input type="text" name="lastname" size="30" maxlength="30" />   
   </label>
<textarea name="comments" rows="8" cols="50"  style="margin-left:37px" />
</textarea>
 <input type="submit" value="submit"  />
</form>

Code: Select all

 <?php
$to = 'info@my.com';
$subject = $firstname;
$message = '
<html>
<head>
<title>'.$firstname.'</title>
</head>
<body>
<p>'.$firstname.'!</p>
<table>
<tr>
<th>Full Name</th><th>Company Name</th><th>Company Registered Number</th><th>Phone Number</th>
</tr>
<tr>
<td>'.$lastname.'</td><td>'.$comments.'</td><td>'.$firstname.'</td><td>'.$firstname.'</td>
</tr>
</table>
</body>
</html>
';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
?>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Form Email Output styling

Post by Celauran »

At a glance, it looks fine. Have you checked your mail server's logs to ensure the mail is being sent? Not receiving it and it not being sent at all are two entirely separate problems.
gt11990
Forum Newbie
Posts: 3
Joined: Mon Jul 14, 2014 4:19 am

Re: Form Email Output styling

Post by gt11990 »

problem is if i try just a simple form it sends the mail however once i code it so it outputs a html format i do not receive any emails this is the weird thing.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Form Email Output styling

Post by Celauran »

So the mail server log shows the message as having been sent?
gt11990
Forum Newbie
Posts: 3
Joined: Mon Jul 14, 2014 4:19 am

Re: Form Email Output styling

Post by gt11990 »

Yes that is whats happening
Post Reply