westman Posted July 3, 2012 Share Posted July 3, 2012 how do i catch a URL link? for example i click a link in this forum to go to my site, how can i catch it in php, witch site a user came to visit me from? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 3, 2012 Share Posted July 3, 2012 If the browser sets it, the referring page is in $_SERVER['HTTP_REFERER']. Not all browsers will set that in all situations. Link to comment Share on other sites More sharing options...
niche Posted July 3, 2012 Share Posted July 3, 2012 (edited) One way to "catch" a link would be to get the referring site to tag your link . See: http://www.w3schools.com/php/php_get.asp Edited July 3, 2012 by niche Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 I'm curious about the use of JavaScript and "history" (object?) to catch same information? Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 One way to "catch" a link would be to get the referring site to tag your link .I'm curious what you mean by this. If the browser is providing referrer information the link will be there. I don't know of any tag that will provide more info if the browser isn't sending a referrer header. Link to comment Share on other sites More sharing options...
westman Posted July 3, 2012 Author Share Posted July 3, 2012 example 2 <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a> </p> how do they do it? Link to comment Share on other sites More sharing options...
niche Posted July 3, 2012 Share Posted July 3, 2012 By tag I mean pass info with the GET array though I haven't used it that way yet. Link to comment Share on other sites More sharing options...
westman Posted July 3, 2012 Author Share Posted July 3, 2012 ok but in...<a href="http://validator.w3.org/check?uri=referer">how does it get my site url? Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 By tag I mean pass info with the GET array though I haven't used it that way yet.OIC! In my case of interest in referrers the sites would not be able to cooperate. Most of my referrals are search engines. I presume the visitors who land on my site (particularly directly to content pages) were referred by search engines but the visitor has their referrer disabled. All the big search engines provide a wealth of information in a query string including in many cases the exact search terms. Very nice! Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 (edited) ok but in...<a href="http://validator.w3.org/check?uri=referer">how does it get my site url?They probably get it from your browser's referrer header. Or maybe you could explain more exactly what your question is. It seems a bit vague to me. Edited July 3, 2012 by So Called Link to comment Share on other sites More sharing options...
westman Posted July 3, 2012 Author Share Posted July 3, 2012 ppl you are missing the piont. am trying to make a system that can catch a url referre how and where do i start? Link to comment Share on other sites More sharing options...
thescientist Posted July 3, 2012 Share Posted July 3, 2012 given that example $ref = $_GET['uri'] Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 It is not us who are missing the point. It is your fault for not explaining what you want. I think we can forgive you because it appears that English is not your native language. Use this in your script: $_SERVER['HTTP_REFERER'] That array element will contain the URL of the site that had a link to your site. This is the same information that you can see in your logs under the "referrer" column. Link to comment Share on other sites More sharing options...
westman Posted July 3, 2012 Author Share Posted July 3, 2012 does ... $ref = $_GET['uri']go on my site to catch the URL? Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 given that example $ref = $_GET['uri'] Or you can use this method if the site sending you traffic can add the information for you. Link to comment Share on other sites More sharing options...
westman Posted July 3, 2012 Author Share Posted July 3, 2012 ok sorry for not giving more info.... i will give a html block like... <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a> </p>to link with my site. more that 1 site will have this link so i need to know witch site is sending me refferels. Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 (edited) That's going to link to validator.w3.org, not to your site. Okay I'm trying to psych what your problem is. Is it this? Let's say you have three sites that link to your site, tom.com, sam.com and harry.com, and your site is example.com. The link on tom.com will be <a href="example.com?url=tom.com>...</a> The link on sam.com will be <a href="example.com?url=sam.com>...</a> The link on harry.com will be <a href="example.com?url=harry.com>...</a> On your site in your index script you'll use $_GET['url'] to see which site linked to you. It will be equal to 'tom.com' or 'sam.com' or 'harry.com' depending on which site's link was clicked. Is that what you wanted to know? Edited July 3, 2012 by So Called Link to comment Share on other sites More sharing options...
westman Posted July 3, 2012 Author Share Posted July 3, 2012 but how does validator.w3.org only use...check?uri=refererand still get url of all diffrent sites? Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 Pardon me while I make an experiment: http://validator.w3.org/check?uri=referer Link to comment Share on other sites More sharing options...
westman Posted July 3, 2012 Author Share Posted July 3, 2012 see at the top of the page we see http%3a%2f%2fw3schools.invisionzone.com%2findex.php%3fshowtopic%3d44191so the url from this site was recivied Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 Okay I just clicked the link that I posted above. Not surprisingly it gets a link to the page we are both on. Being a PHP genius ( ) I can tell you that w3.org ignored the ?uri=referrer part of the link and instead they used $_SERVER['HTTP_REFERER'] in their script that catches the page request. Because that's the only way it could possibly be working. Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 (edited) Wow! "Validation Output: 106 Errors" You would think a forum about web design would validate perfectly. Another experiment: http://validator.w3.org/checkAnother experiment: http://validator.w3.org/check?uri= Edited July 3, 2012 by So Called Link to comment Share on other sites More sharing options...
westman Posted July 3, 2012 Author Share Posted July 3, 2012 ok thank you last 1, can i use it like this? <?php$new_url = $_SERVER['HTTP_REFERER']?> Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 Another experiment: http://validator.w3.org/checkAnother experiment: http://validator.w3.org/check?uri= Okay I can see now more about what is happening. Neither of the above works. Conclusion: The query string ?uri=referer tells the validator to use the referrer string sent by the browser as the URL to be validated. It is getting that from $_SERVER['HTTP_REFERER'] if they are using PHP. Another experiment: Paste the entire URL into a new browser window and try that. You'll get this error message from w3.org: "No Referer header found!" That proves that they are using the "referer" header when you have ?url=referer in the link, because it fails when there is no "referer" header. (The correct spelling is "referrer" but due to the first guy who designed it being an idiot he misspelled it "referer" and it's been too complicated to fix his original mistake. It's the programming equivalent of the dummy who thought electricity current flowed from + to - because they didn't know what electrons were back then, so now we have current flow and electron flow in the opposite directions. But I digress...) Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 (edited) Another experiment: http://validator.w3..../wiki/Main_Page Edit: I'm breaking it up so you can see the actual URL: http:// validator.w3. org/check ?url=http:// en.wikipedia. org/wiki/Main_Page Edited July 3, 2012 by So Called Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now