jasonX
06-13-2002, 03:31 PM
Does anyone know how to set a cookie, that tells where the user came from when they enter your main page. Then, even if they come back a week later, (doesn't matter where they come from) and then place an order, have the order form report the refferer contents of the cookie to you, so you can possibly track where that original reffer cam from. Is this possible? if so, how do you do it?
Thanks.
Marty
06-13-2002, 04:36 PM
If you know a little php you could to it with www.php.net/setcookie
Of course you would want to enclose it in an if statement to check whether they already have the cookie present from a previous visit. Something like this
<?php
if (empty($referer)){
setcookie ("referer", $HTTP_REFERER,time()+2592000);
}
?>
Make sure that this code is at the very top of the page without even any white space before it. It should be before your opening <html> tag.
Then you would have to echo it into your form by putting the following code where you want it.
<?=$referer ?>
Of course, the pages with this code will need to have .php extensions.
jasonX
06-13-2002, 08:19 PM
thanks! that set the cookie. Now.. As to implementing this in my order form..
Look near the bottom, and you can see the referrer part. It doesn't come through when someone submits an order form though. How woould I make it correctly come through e-mail?
<?
include("ordercomplete.inc.php");
$message = "<HTML>\n";
$message .= "<b>Reseller Web Host Order Form</b><br>\n<br>\n";
$message .= "<i>Personal Information</i><br>\n";
$message .= s_bar();
$message .= s_table();
$message .= s_item("Name",$name);
$message .= s_item("Organization",$org);
$message .= s_item("Address",$address);
$message .= s_item("City", $city);
$message .= s_item("State", $state);
$message .= s_item("Country", $country);
$message .= s_item("Zip", $zip);
$message .= s_item("Phone", $phone);
$message .= s_item("E-Mail", $email);
$message .= s_item("Referral",$where);
$message .= s_item("Other", $where2);
$message .= s_etable();
$message .= s_next("Ordering Information");
$message .= s_item("Registration", $regyn);
if ($domain)
$message .= s_item("Domain Name", $domain);
$message .= s_item("Package", $pack);
$message .= s_item("Payment Frequency",$pfreq);
$message .= s_etable();
$message .= s_next("<i>Credit Card Information</i><br>\n");
$message .= s_item("Card Type", $poptions);
/* introduction of $mmessage */
// sprintf($mmessage, "%s", $message);
$mmessage = "$message";
$mmessage .="<tr><td width='20%'>Card Number :</td><td>";
if (strlen($cnumber) > 14)
{
$mmessage .= str_repeat("*", 12);
$mmessage .= substr($cnumber, 12);
} else $mmessage .= "<b>Not Displayed</b>";
$mmessage .= "</td></tr>\n";
$message .= s_item("Card Number", $cnumber);
$message .= s_item("Expiration Date", $expiration);
$message .= s_item("Name on card", $cname);
$message .= s_next("Misc.");
$mmessage .= s_item("Expiration Date", $expiration);
$mmessage .= s_item("Name on card", $cname);
$mmessage .= s_next("Misc.");
$mmessage .= s_item("IP Address",$REMOTE_ADDR);
if ($terms)
{
$message .= s_item("Accepted AUP", "Yes");
$mmessage .= s_item("Accepted AUP", "Yes");
}
$message .= s_item("IP Address",$REMOTE_ADDR);
if ($S1)
{
$message .= s_item("Special Instructions", $S1);
$mmessage .= s_item("Special Instructions", $S1);
}
$message .= "$referer";
$message .= "</table><br><center><b>-- End of message --</b></center><br>\n";
$mmessage .= "</table><br><center><b>-- End of message --</b></center><br>\n";
if ($terms != "0")
{
printdenied("<br><H3>Sorry, but you must accept the terms of service before you continue. <a href='javascript:history.go(-1)'>Back</b><a><br>\n");
exit;
} else if (!$domain) {
printdenied("<br><H3>Sorry, but you must enter a domain name to use before you continue. <a href='javascript:history.go(-1)'>Back</b><a><br>\n");
exit;
} else {
mail("jasonx@yahoo.com","RESELLER Hosting Request for $name",$message, "From: orders@hostingsite.com\nOrder-form: True");
mail("jasonx@yahoo.com","RESELLER Hosting Request for $name",$message, "From: orders@hostingsite.com\nOrder-form: True");
printme($mmessage);
}
?>
GlideTech
06-13-2002, 11:23 PM
Try changing
$message .= "$referer";
to
$message .= $referer;
GlideTech
06-14-2002, 08:22 AM
Sounds like the cookie isnt getting set then.
Try to make a new file:
<?
echo $referer;
?>
If it doesnt echo the referer to the screen, the cookie is most likely not set.
jasonX
06-14-2002, 02:23 PM
No, that works. It echos the reffer just fine. :confused:
GlideTech
06-14-2002, 02:26 PM
<snip> its obviously been a while since Ive played with php :) </snip>