Is it possible to get the URL I am at using PHP, so I can store it in a variable and send it to the next site I am going to? Or do I have to use JS to do that?
Printable View
Is it possible to get the URL I am at using PHP, so I can store it in a variable and send it to the next site I am going to? Or do I have to use JS to do that?
Oddly enough, that happens automaticaly in most placed. Called the HTTP REFERER.
TG
Thanks...couldn't find anything about it in my 2 PHP books, or in my HTML book, but after seacrhing this forum up and down I finaly found out what you where talking about.
Most of the answers where just talkinag about it, nothing more...but here is some help for the next person searching...;)
http://www.vbforums.com/showthread.p...hlight=REFERER
BTW your home site does not validiate...take away your badge of honor...:D
http://validator.w3.org/check?uri=ht...website.net%2F
Come on Note, you not search the forum ;)
http://www.vbforums.com/showthread.p...hreadid=289337
Its still on the page, only a couple down. :D.
And I wouldn't relie on the REFFERER thing becuase it can be disabled by most Security Programs. I had that problem a while back :D.
Quote:
Originally posted by Electroman
Come on Note, you not search the forum ;)
http://www.vbforums.com/showthread.p...hreadid=289337
Its still on the page, only a couple down. :D.
And I wouldn't relie on the REFFERER thing becuase it can be disabled by most Security Programs. I had that problem a while back :D.
First of all, I didn't know what to search for. And second of all, what security app are you talking about. Apps on the clients PC?
And other thing, the thread you posted a link to....isn't that only printing the name of the current page? :confused:
HTTP REFERER will tell you where you jsut came from. That's how refere links/tracking works. When you go from say, www.vbforums.com to www.developerkb.com, part of the header data is that the last page you were on was at vbf. BUT, there are some firewalls and proxy servers that block that kind of data from being transmitted.
TG
So is there a safe way to get the last page without sending it as as a variable from all my pages? Or should I just use for the the clients that can use it, and check if it is "" for all other users and send them to a defualt page if it is empty?
Things like Norton Security has a privicy option where it will stop any browser your using from passing on the REFFERER header. Can't remember which user it was but he had a page which let you downlaod a files of his but it checked you had came from his site and it hadn't been linked to from else where. It thought I waas coming from another site because the refferer didn't have his website in it (It was blank).
The thread I linked to shows: $_SERVER["SCRIPT_NAME"]; which hold the address of the script file, he then split it up to get just the filename. If you skip the splitting part you should have a variable which the current pages address. Notice it won't include and parameter pairs sent with it but you can easily loop through the $_GET[] array to get all of them andadd them if that what you need.
I'll let you off on the searching though ;) ;).
But isn't that only going to tell you where you ARE, and not where you WERE? Or dod I miss something?Quote:
Originally posted by Electroman
Things like Norton Security has a privicy option where it will stop any browser your using from passing on the REFFERER header. Can't remember which user it was but he had a page which let you downlaod a files of his but it checked you had came from his site and it hadn't been linked to from else where. It thought I waas coming from another site because the refferer didn't have his website in it (It was blank).
The thread I linked to shows: $_SERVER["SCRIPT_NAME"]; which hold the address of the script file, he then split it up to get just the filename. If you skip the splitting part you should have a variable which the current pages address. Notice it won't include and parameter pairs sent with it but you can easily loop through the $_GET[] array to get all of them andadd them if that what you need.
I'll let you off on the searching though ;) ;).
TG
Yeah you pass that variable when the user follows a link and you know where the user was last on your site ;).
Quote:
Originally posted by techgnome
But isn't that only going to tell you where you ARE, and not where you WERE? Or dod I miss something?
TG
That was what I was asking about too..:D
OK...I get it now...but I still don't like it...then I still have to write it on all the pages I want to use it...:(....But I will live....Quote:
Originally posted by Electroman
Yeah you pass that variable when the user follows a link and you know where the user was last on your site ;).
how about this variable gets stored in a cookie instead of being part of the address to the next page? That would work but may come up with strange results if they have more than one page open on your site.
Ow I now get why it wasn't very usefull to start with :(. You could just make a constant in all the fiels instead of this. I see now techgnome was on the right lines by the refferer thing. Mind I still wouldn't trust it to tell the truth. You could of course just bugger it up for people that stop the refferer from being sent. I'm sure they deserve it, its not as if its important info in it.
OK, so stuff it into a variable, then what? It still needs to get to the new page somehow.Quote:
Originally posted by Electroman
Yeah you pass that variable when the user follows a link and you know where the user was last on your site ;).
Cookie may not work either. You'ld have to set the cookie, then reset the location back to the same page to get the cookie to stick.Quote:
Originally posted by Electroman
how about this variable gets stored in a cookie instead of being part of the address to the next page? That would work but may come up with strange results if they have more than one page open on your site.
Ow I now get why it wasn't very usefull to start with :(. You could just make a constant in all the fiels instead of this. I see now techgnome was on the right lines by the refferer thing. Mind I still wouldn't trust it to tell the truth. You could of course just bugger it up for people that stop the refferer from being sent. I'm sure they deserve it, its not as if its important info in it.
Also does $_SERVER["SCRIPT_NAME"]; retain any querystring data?
TG
EDIT: Either way, it jsut seems to me that there should be a better way.
The idea was to send it by GET, everywhere the next page would need it add in onto the link as a paramter.Quote:
Posted by techgnome
OK, so stuff it into a variable, then what? It still needs to get to the new page somehow.
Nope.Quote:
Posted by techgnome
Also does $_SERVER["SCRIPT_NAME"]; retain any querystring data?
Yeah I don't think the cookie ideas was that great either :(
I will just use the Referer for now. And if I get some time in the end I will change it ans send it as a variable and use SCRIPT_NAME.....:(