Jump to content

no anchor $_SERVER['HTTP_REFERER']


jakebur01

Recommended Posts

How can I get http_referer to retrieve the anchor in the url?  It keeps url variables, but it does not get the anchor.

 

Example:

 

http://example.com/ex.php?id=10#tab=3

 

 

All http_referrer catches is http://example.com/ex.php?id=10

 

code:

$refer = $_SERVER['HTTP_REFERER'];
<script type="text/javascript">
<!--
window.location = "<?PHP echo"$refer";?>"
//-->
</script>

Link to comment
https://forums.phpfreaks.com/topic/230564-no-anchor-_serverhttp_referer/
Share on other sites

Anchor tags are not passed to the server. Only the browser sees them and can act on them. If you want PHP to see an anchor tag, you would have to capture it with Javascript and send the value to PHP via AJAX. See http://www.w3schools.com/jsref/prop_loc_hash.asp for how to capture the hash via Javascript.

 

Ken

Still searching on how to store a javascript value into a php variable.  I haven't figured it out yet.

<?PHP $hash="<script type=text/javascript>

document.write(location.hash);

</script>"; ?>

<input type="hidden" name="hash" id="textfield" value="<?php echo"$hash";?>"/>

 

I basically have a page for updating information with 4 or 5 different tabs to navigate between.  When the info is saved, I submit/post to the same page and I have an if $_POST statement at the top of the page that catches it.  I am then trying to redirect to the the same page and same anchor.

 

 

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.