I’ve adding the “forward to a friend” code to the following site I’m working on (in the right rail):
http://dealeradvantage.cars.com/bestofda/bestofda8.php
My client is able to receive the email with the actual URL in it that someone is referring them to. BUT when they fill out the form and it is sent via email to another user, the URL of the referral page is not showing up. Any suggestions???
Also, here’s my code:
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Best of Dealer ADvantage from Cars.com<</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
<style type="text/css">
<!--
A:link
{
color: #3B0084;
font-weight: bold;
text-decoration: none;
}
A:active
{
color: #3B0084;
font-weight: bold;
text-decoration: none;
}
A:visited
{
color: #3B0084;
font-weight: bold;
text-decoration: none;
}
A:hover
{
color: #3B0084;
font-weight: bold;
text-decoration: underline;
}
-->
</style>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<table width="450" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td width="135" bgcolor="#FFFFFF"><img src="images/pixel.gif" alt="pixel" width="130" height="1" align="left" style="margin:0px 0px 15px 0px"></td>
<td bgcolor="#FFFFFF"><img src="images/bda_header.gif" alt="bdaheader" width="180" height="24" border="0" style="margin:5px 0px 10px 0px"></td>
<td width="135" bgcolor="#FFFFFF"><img src="images/pixel.gif" alt="pixel" width="130" height="1" align="right" style="margin:0px 0px 15px 0px"></td>
</tr>
</table>
<?
$status = "OK";
$msg="";
if (!stristr($y_email,"@") OR !stristr($y_email,".")) { // checking your email
$msg .="Your email address is not correct<BR>";
$status= "NOTOK";}
if (strlen($y_name) <2 ) { // checking your name
$msg .="Please enter your name<BR>";
$status= "NOTOK";}
if (!stristr($f_email,"@") OR !stristr($f_email,".")) { // checking friends email
$msg .="Your friend's email address is not correct<BR>";
$status= "NOTOK";}
if (strlen($f_name) <2 ) { // checking freinds name
$msg .="Please enter your friend's name<BR>";
$status= "NOTOK";}
if($status=="OK"){ // all validation passed
/////////// Sending the message starts here //////////////
$ref=@$HTTP_REFERER;
/////Message at the top of the page showing the url////
$header_message = "Hi $f_name, n Your friend $y_name is requesting you visit a Best of DealerADvantage page at n $ref n";
/// Body message prepared with the message entered by the user ////
$body_message = $header_message. "n $y_name also sent you the following message:n $y_msg";
//// Mail posting part starts here /////////
$headers="";
//$headers = "Content-Type: text/html; charset=iso-8859-1n".$headers;
// Un comment the above line to send mail in html format
$headers4=$y_email; // Change this to change from address
$headers.="Reply-to: $headers4n";
$headers .= "From: $headers4n";
$headers .= "Errors-to: $headers4n";
$subject="Best of Dealer ADvantage from Cars.com";
mail($f_email,$subject,$body_message,$headers);
////// Mail posting ends here ///////////
echo "<center><font face='Verdana' size='2' color=#3B0084>Thank you for sharing the news from the Best of DealerADvantage.<br /> Your message has been sent to <b>$f_name</b></font></center>";
//////////// Sending the message ends here /////////////
}else{// display the error message
echo "<center><font face='Verdana' size='2' color=red>$msg</font></center>";
}
?>
</body>
</html>
ADMIN EDIT: Added the bbcode tags for CODE to make it more readable. Refer to http://phphelp.com/forums/viewtopic.php?t=2752