...

View Full Version : file_get_contents--->email comes have html code in it and NOT graphic/text...?



lse123
06-06-2007, 09:19 PM
http://www.louravilla.com/pch/apply_aff.php
I try the file_get_contents('email-manual.php'); to above webpage but email comes have html code in it and NOT graphic/text...? The message comes is the same as confirm page and about 95% same as html form see below:
I also include email received , well ?

<?php

/* recipients */
$email = $_POST['email'];
$to = "a080725@cytanet.com.cy";
if ($email != '') { $to .= ','.$email; }

$subject = "Affiliate Sign-Up Request - PafosCarHire.com"; // new form field

$first = $_POST['first'];
$last = $_POST['last'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$company = $_POST['company'];
$biz = $_POST['biz'];
$title = $_POST['title'];
$country = $_POST['country'];
$url = $_POST['url'];
$type = $_POST['type'];
$visitors = $_POST['visitors'];
$notes = $_POST['notes'];

$message = file_get_contents('apply_aff_email.php');

$headers = "From:a080725@cytanet.com.cy";
$headers .= "\nBcc: $email";
$headers .= "\nReply-To:a080725@cytanet.com.cy";

$sentOk = mail($to,$subject,$message,$headers);
echo "sentOk=" . $sentOk;


include_once ("apply_aff_email.php");

?>

email---to a080725@cytanet.com.cy
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>New Affiliate Sign Up</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head>

<body>
<p> <!-- #BeginLibraryItem "/Library/top.lbi" -->
<div align="center"><b><font size="4"><b><font face="Arial" color="#0000ff"><a name="TOP"></a></font></b></font><font face="Arial" color="#0000FF" size="2"><a href="index.php" style="text-decoration: none">Home</a>&nbsp; -&nbsp; <a href="about_us.php" style="text-decoration: none">About
Us</a>&nbsp; -&nbsp; <a href="fleet.php" style="text-decoration: none">Our
Fleet</a>&nbsp; -&nbsp; <a href="rates.php" style="text-decoration: none">Rates</a>&nbsp; -&nbsp; <a href="terms.php" style="text-decoration: none">Terms</a>&nbsp; -&nbsp; <a href="reservations.php" style="text-decoration: none"> Reservations</a>&nbsp; -&nbsp; <a href="contact_us.php" style="text-decoration: none">Contact
Us</a></font></b></div>
<!-- #EndLibraryItem -->
</p>
<p>&nbsp; </p>
<table width="550" height="509" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="154" colspan="2" valign="top" class="text1"><p align="center"><img src="http://www.louravilla.com/pch/images/affiliate.gif" width="337" height="48"></p>
<p>To join the program please complete the form below and one of <br>
our webmasters will be in contact with you shortly. <br>
<br>
* = Required fields <?= $first ?> <br>
</p></td>
</tr>
<tr bgcolor="#CCCCCC">
<td valign="top" class="text1"><div align="center">First Name* : </div></td>
<td width="50%" valign="top">
<p>
<input name="first" type="text" id="first" value="<?= $first ?> " size="40" maxlength="100"> </p></td>
</tr>
<tr>
<td class="text1" valign="top"><div align="center">Last Name* : </div></td>
<td valign="top"><input name="last" type="text" id="last" value="<?php echo "$last" ?>" size="40" maxlength="100"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td valign="top" class="text1"><div align="center">Email* : </div></td>
<td valign="top"> <input name="email" type="text" id="email" value="<?php echo $email ?> " size="40" maxlength="100"></td>
</tr>
<tr>
<td class="text1" valign="top" width="50%"><div align="center">Phone* : </div></td>
<td valign="top">
<input name="phone" type="text" id="phone" value="<?php echo "$phone" ?>" size="40" maxlength="40"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td valign="top" class="text1"><div align="center">Fax: </div></td>
<td valign="top"><input name="fax" type="text" id="fax" value="<?= $fax ?> " size="40" maxlength="40"></td>
</tr>
<tr>
<td class="text1" valign="top"><div align="center">Company (firm) name* : </div></td>
<td valign="top">
<input name="company" type="text" id="company" value="<?= $company ?> " size="40" maxlength="100"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td valign="top" class="text1"><div align="center">Company main business*
: </div></td>
<td valign="top">
<input name="biz" type="text" id="biz" value="<?= $biz ?> " size="40" maxlength="100"></td>
</tr>
<tr>
<td class="text1" valign="top"><div align="center">Position/Title (within
company)* : </div></td>
<td valign="top">
<input name="title" type="text" id="title" value="<?= $title ?> " size="40" maxlength="100"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td valign="top" class="text1"><div align="center">Country, State* : </div></td>
<td valign="top">
<input name="country" type="text" id="country" value="<?= $country ?> " size="40" maxlength="100"></td>
</tr>
<tr>
<td class="text1" valign="top"><div align="center">Website URL* : </div></td>
<td valign="top">
<input name="url" type="text" id="url" value="<?= $url ?> " size="40" maxlength="100"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td valign="top" class="text1"><div align="center">Type of Website* : </div></td>
<td valign="top">
<input name="type" type="text" id="type" value="<?= $type ?> " size="40" maxlength="100"></td>
</tr>
<tr>
<td class="text1" valign="top"><div align="center">Unique visitors per month*
: </div></td>
<td valign="top">
<input name="visitors" type="text" id="visitors" value="<?= $visitors ?> " size="40" maxlength="40"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td height="89" valign="top" class="text1"><div align="center">Notes: </div></td>
<td valign="top"><label>
<textarea name="notes" cols="36" rows="5" id="notes"><?= $notes ?>
</textarea>
</label></td>
</tr>
<tr>
<td valign="top"></td>
<td valign="top" align="right"></td>
</tr>
</table>
<p>&nbsp;</p>
<!-- #BeginLibraryItem "/Library/bottom.lbi" -->
<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
}
-->
</style>
<p align="center" style="margin-top: 0; margin-bottom: 0"><b><font face="Arial" color="#0000FF" size="2"><a href="index.php" style="text-decoration: none">Home</a>&nbsp; -&nbsp; <a href="about_us.php" style="text-decoration: none">About
Us</a>&nbsp; -&nbsp; <a href="fleet.php" style="text-decoration: none">Our
Fleet</a>&nbsp; -&nbsp; <a href="rates.php" style="text-decoration: none">Rates</a>&nbsp; -&nbsp; <a href="terms.php" style="text-decoration: none">Terms</a>&nbsp; -&nbsp; <a href="reservations.php" style="text-decoration: none"> Reservations</a>&nbsp; -&nbsp; <a href="contact_us.php" style="text-decoration: none">Contact Us</a></font></b></p> <p align="center" style="margin-top: 0; margin-bottom: 0"><font face="Arial" size="2">Copyright<b> </b>&copy; 200<span lang="en-gb">7</span>&nbsp; </font> <span class="style1"><font size="2">Pafos
Car Hire</font> </span><font face="Arial" size="2"> @ POLIS&nbsp;&nbsp;&nbsp;All
rights reserved</font></p>
<!-- #EndLibraryItem --><p>&nbsp; </p>
</body>
</html>

kbluhm
06-06-2007, 09:22 PM
No content type is specified, so it is sending as text/plain by default.

And if you're just getting the contents of the file, the code will not be parsed... it will be sent and viewed just the same as it looks when you have the file opened locally in a text-editor.

To parse the file and get the desired output, change this:


$message = file_get_contents('apply_aff_email.php');


...to this:


ob_start();
include('apply_aff_email.php');
$message = ob_get_clean();


And add this to $headers to make it an HTML email:


$headers .= "\nContent-Type: text/html; charset=UTF-8";
$headers .= "\nMIME-Version: 1.0";


You also have some repetitive code, such as:


$email = $_POST['email'];


And be sure to sanitize the user-submitted information, such as checking if the email is properly formatted. Your code is open to header injection.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum