Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.