Jump to content

Archived

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

bob_the _builder

Using $_SERVER["HTTP_REFERER"] in a link

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

Share this post


Link to post
Share on other sites
Uus $_SERVER['QUERY_STRING'] to get the query string from the url, the bit after the question mark

$url = $_GET['REFERER'] . '?' . $_SERVER['QUERY_STRING'];

Share this post


Link to post
Share on other sites
[quote]Is it bad pratice sending the url across like that to $_GET it at the destination?[/quote]

Its quite common practice really.

Share this post


Link to post
Share on other sites
Still not working .. Tried:

&referer='.$_SERVER["HTTP_REFERER"].'?'.$_SERVER['QUERY_STRING'].'

and:

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

but still get:

http://localhost/gallery/index.php?action=sh_subcat

but it should be:


http://localhost/gallery/index.php?action=sh_subcat&subcatid=4


Thanks

Share this post


Link to post
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'])

Share this post


Link to post
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??

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites
lounger for now post your code over at http://www.pastebin.com

Also are you asking bob_the _builder for help, or are you in some way trying to help bob_the _builder? If you are asking for help then post in your own topic. Dont [i]hijack[/i] other peoples threads.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
I didnt say go away, just post your code over at pastebin.com then provbide the link to the code you pasted over at pastebin.com. Also read your thread you posted earlier [url=http://www.phpfreaks.com/forums/index.php/topic,106564.0.html]here[/url]

Share this post


Link to post
Share on other sites

×

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.