Jump to content

Using $_SERVER["HTTP_REFERER"] in a link


bob_the _builder

Recommended Posts

Hi,

When I use $_SERVER["HTTP_REFERER"] within a link like:

[code=php:0]<a href="index.php?action=delete&subcat_id='.$_GET['subcat_id'].'&confirm=y&referer='.$_SERVER["HTTP_REFERER"].'">Yes</a>[/code]


and try to call on $_GET['referer'] to redirect user back:


[code=php:0]<meta http-equiv="refresh" content="3; url='.$_GET['referer'].'">';[/code]


$_GET['referer'] only seems to hold the value:


[code=php:0]http://localhost/gallery/index.php?action=sh_subcat[/code]


but it should be:


[code=php:0]http://localhost/gallery/index.php?action=sh_subcat&subcatid=4[/code]


Seems that it takes out everthing after the & in the above url?

Is there a work around for that?

Thanks
Link to comment
Share on other sites

Try this:

[code=php:0]$referer = urlencode($_SERVER["HTTP_REFERER"]. '?' .$_SERVER['QUERY_STRING']);
echo '<a href="index.php?action=delete&subcat_id=' . $_GET['subcat_id'] . '&confirm=y&referer=' . $referer . '">Yes</a>';[/code]

When you retrieve the referer you'll need to urldecode($_GET['referer'])
Link to comment
Share on other sites

hey bob

i too am having trouble with a script which uses this $ref=@$HTTP_REFERER; but unfortunatly i am unable to post it here as the system always says The page cannot be displayed, i need the script to get the pic url and not the browser url ,any ideas how i can post my script so that everone can see it??
Link to comment
Share on other sites

hi bob

i have a send a page to your friends script on a web page in my site but this sends the recipient the browser url, this is bad because it means that when this url link is clicked the peson who clicked it is actually in the senders account and can cause lots of mischeif eg. delete files ect. what i need is the script to send the image url instead which is also shown on my web page but i do not know how to make the script use that url instead of the browser url.

i cant post the script as this forum throws me out and shows me the page -The page cannot be displayed i cant even post a snippet or am i doing somthing wrong?? im just cut and pasting it on here?

Link to comment
Share on other sites

ok ill post in pastebin, im not hijacking anything im just giving bob support as i too am in a similar situation with i think the same problem??

and bob i was only tring to post one line so im not sure why it wont let me but ill try the other site now good luck with that buddy.
Link to comment
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.