Jump to content

[SOLVED] Page Tracking Issue


phpQuestioner

Recommended Posts

I have already designed this page in HTML and all my link on this site are linked to this html page. I am trying to get the address of the page that accesses this HTML page. I tried to use a PHP/Javascript external file with HTTP_REFERER set as a Javascript variable and then use Javascript inside the HTML page to load the content of the PHP/Javascript Variable into a hidden form field. But instead of showing me the previous page that had accessed my HTML page; it just displays the HTTP_REFERER for the HTML page (the html page's address).

 

Here is the code I used:

 

HTML

 

<script type="text/javascript" src="myexternalscripts.php"></script>
<script language="javascript">
function loadMyVars() {
document.myForm.direction.value=""+previous+"";
}
window.onload=function() {
loadMyVars();
}
</script>

<form name="myForm" method="post" action="formprocessorpage.php">
<input type="hidden" name="direction">
<input type="submit">
</form>

 

PHP/Javascript (myexternalscripts.php)

 

<?php

$referral = $_SERVER['HTTP_REFERER'];

echo "var previous=\"$referral\";";

?>

 

Anyone know how I can use HTTP_REFERER in my HTML to display the page that last accessed my HTML page in a hidden form field?

Link to comment
https://forums.phpfreaks.com/topic/68984-solved-page-tracking-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.