Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PHP html email is showing code when it comes into email

Posted on 2010-09-17
5
389 Views
Last Modified: 2012-05-10
Hello,

I have a form that submits information into a Mysql database then sends an email to the dealer. It was working fine (showing an html email formatted nicely) and yesterday i added a "heard_about" field to the database, form, and the insert script. Now when the email comes over it's showing all the html code?? I can't seem to figure out why that would start doing that? here's what the email looks like now:

0
Comment
Question by:remedy_rider
  • 3
  • 2
5 Comments
 

Author Comment

by:remedy_rider
ID: 33702235
I guess the code would help...duh!! sorry.

thanks in advance for looking at this!

<?php

	   
 include("connection.php");

$sql="INSERT INTO 2010_contest (fname, lname, phone, email, address, city, state, zip, heard_about, q1, q2)
VALUES
('$_POST[fname]','$_POST[lname]','$_POST[phone]','$_POST[email]','$_POST[address]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[heard_about]','$_POST[q1]','$_POST[q2]')";
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
 $id = mysql_insert_id(); 
  {

$fname = $_REQUEST['fname'] ;
$lname = $_REQUEST['lname'] ;
$Phone = $_REQUEST['phone'] ;
$Address = $_REQUEST['address'] ;
$HeardAbout = $_REQUEST['heard_about'] ;
$City = $_REQUEST['city'] ;
$State = $_REQUEST['state'] ;
$Zip = $_REQUEST['zip'] ;
$email = $_REQUEST['email'] ;
$q1 = $_REQUEST['q1'] ;
$q2 = $_REQUEST['q2'] ;


$fromAddr = 'admin@harley-superstore.com'; // the address to show in From field.
//$recipientAddr = 'sirons@manchesterhd.com';
$recipientAddr = 'scott@velocityinc.com';
$subjectStr = '2010 HSS contest submission';

$mailBodyText = <<<HHHHHHHHHHHHHH
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>2010 HD contest submission</title>
</head>
<body>
<p>
<strong>$fname  $lname</strong> signed up for the contest to win the Harley. <br><br>
Here is their information to enter into the administration area:<br><br>
First Name: <strong>$fname</strong><br><br>
Last Name: <strong>$lname</strong><br><br>
Address: <strong>$Address</strong><br><br>
City: <strong>$City</strong><br><br>
State: <strong>$State</strong><br><br>
ZipCode: <strong>$Zip</strong><br><br>
Phone: <strong>$Phone</strong><br><br>
Email: <strong>$email</strong><br><br>
Heard About HSS: <strong>$HeardAbout</strong><br><br>
Queston 1: <strong>$q1</strong><br><br>
Queston 2: <strong>$q2</strong><br><br>


</p>
</body>
</html>
HHHHHHHHHHHHHH;

$headers= <<<TTTTTTTTTTTT
From: $fromAddr
MIME-Version: 1.0
Content-Type: text/html;
TTTTTTTTTTTT;

mail( $recipientAddr , $subjectStr , $mailBodyText, $headers);

  //send email to supported rider
$fromAddr = 'sales@harley-superstore.com'; // the address to show in From field.
$recipientAddr = $email;
$subjectStr = 'Harley-Superstore HD contest 2010';

$mailBodyText = <<<HHHHHHHHHHHHHH
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Win a Harley Contest</title>
</head>
<body>
<p>
Hello, <br><br> $fname we recieved your submission for the contest.  <br><br>
Contest winner will be announced via the website and email. <br><br>
Thank you for participating!<br><br>
The Harley-Superstore.com

</p>
</body>
</html>
HHHHHHHHHHHHHH;

$headers= <<<TTTTTTTTTTTT
From: $fromAddr
MIME-Version: 1.0
Content-Type: text/html;
TTTTTTTTTTTT;

mail( $recipientAddr , $subjectStr , $mailBodyText, $headers);
  
  header("Location: http://www.harley-superstore.com/contest_confirm.php");
 
  }

Open in new window

0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 33703116
I would try adding "\r\n" to the end of the header.  Not sure if that semicolon after Content-Type: text/html needs to be there.  I also wonder about having more than one HEREDOC declaration with the same name.

Have you gone back to your old version and compared the code line-for-line?
0
 

Author Comment

by:remedy_rider
ID: 33718766
Sorry for the slow response Ray, I was gone this weekend and out half day today. I went through the code like you said and i did find a close bracket missing and yes the \rn\ seemed to work! Thanks!
0
 

Author Closing Comment

by:remedy_rider
ID: 33718772
It's fixed!
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 33719427
Great!  Thanks for the points, ~Ray
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dynamic Dropdowns 15 32
jQuery Toggle & Anchor Links 5 43
Ajax and PHP 9 29
insert ID of database value into database instead of text value from text field 23 22
Creating and Managing Databases with phpMyAdmin in cPanel.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question