View Full Version : PHP HELP and ASP
OptWizard
13-01-2004, 14:09/02:09PM
I have ascript on my page to track referers it works great but this is what I need tweaked
Say if someone comes from google to the home page then goes to app page I need the google ref captured
meaning
I have script on home page and app page but if someone goes to app from my home page it does not keep the original ref captured? I hope I explained this right?
I am having same problem with ASP
dvduval
14-01-2004, 23:23/11:23PM
You should be able to capture the info in a session variable.
AndrewB
15-01-2004, 01:38/01:38AM
Yep to be more specific do this on your homepage
$_SESSION['referer_url'] = $_SERVER['HTTP_REFERER'];
then on access the variable $_SESSION['refferer_url'] on any of your pages
OptWizard
15-01-2004, 10:06/10:06AM
SO How would I right this code exactly.....
and it would capture the original referer? Meaning if someone came from google to home page to app it would capture google?
OptWizard
15-01-2004, 10:42/10:42AM
Correct me if I am wrong I put this on top of my index page only
<?php
$_SESSION['test'] = $_SERVER['HTTP_REFERER'];
?>
and this I put on the bottom of the index page
<?php echo "<input name='Ref' type='hidden' value='".$test."'>";?>
Now on the quote page I just out this in the body
<?php
if (isSet($_SESSION["test"])) {
?>
<input name="Ref" type="hidden" value="<? echo($_SESSION["test"]);?>">
<?php
}
else {
if (!isSet($_GET["test"])) {
$_SESSION["test"] = $_SERVER['HTTP_REFERER'];
}
}
?>
<input name="Ref" type="hidden" value="<? echo($_SESSION["test"]);?>">
This will then capture the referer from where they searched from and it will follow throught the page...now if they came right to the site it will put the page they came from on the site correct?
AndrewB
15-01-2004, 12:29/12:29PM
Yes what you have done is ok but I'm not sure why you need a hidden input tag that holds the refferal string when it's already stored in the variable $_SESSION['test'] which can be accessed throughout your pages as long as your got session_start() on them.
I think i've seen you store session variables in hidden input tags before. The only need for that would be if u had some sort of javascript on the page that might need that hidden <input> tag data to be displayed or something to the user.
when your adding the data to your database you just use the variable $_SESSION['test'] I think perhaps your thinking you need to use $_POST['Ref'] when the user submits the form
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.