phileplanet Posted June 20, 2006 Share Posted June 20, 2006 Is there a way for me to determine if a link has been visited using PHP? Quote Link to comment https://forums.phpfreaks.com/topic/12483-visited-links/ Share on other sites More sharing options...
zq29 Posted June 20, 2006 Share Posted June 20, 2006 You could probably search through your raw server logs with strpos([i]haystack[/i],[i]needle[/i]) Quote Link to comment https://forums.phpfreaks.com/topic/12483-visited-links/#findComment-47801 Share on other sites More sharing options...
phileplanet Posted June 21, 2006 Author Share Posted June 21, 2006 It may not be on my site though. Let's say the user visited google.com. Is there anyway I can find out if they did using a function or something? Quote Link to comment https://forums.phpfreaks.com/topic/12483-visited-links/#findComment-47907 Share on other sites More sharing options...
wildteen88 Posted June 21, 2006 Share Posted June 21, 2006 $_SERVER['HTTP_REFERER']That variable stores the last location the user come from. Quote Link to comment https://forums.phpfreaks.com/topic/12483-visited-links/#findComment-47973 Share on other sites More sharing options...
phileplanet Posted June 21, 2006 Author Share Posted June 21, 2006 Sorry maybe I'm not saying it properly.Basically, I have a list of links to external sites. If the user clicks on a link and then refreshes the page, I want to display an image next to that link that says they have visited it.I know you can do this in CSS with :visited but I need to apply it to something besides an anchor.Hope this explains it better. Quote Link to comment https://forums.phpfreaks.com/topic/12483-visited-links/#findComment-48157 Share on other sites More sharing options...
Buyocat Posted June 21, 2006 Share Posted June 21, 2006 You would need a way to track users, that is either through a cookie or through a database. Once that is decided then you can simply create an array in the cookie with the links visited and when the page is loaded it checks that array and adds anchors accordingly. Otherwise if you want to use a database you would have it query for a user and links visited then act accordingly after that. I think both have their advantages; the cookie method is much much easier but also can be undone by deleting cookies. The user method is more complicated but also more permanent. Quote Link to comment https://forums.phpfreaks.com/topic/12483-visited-links/#findComment-48162 Share on other sites More sharing options...
phileplanet Posted June 21, 2006 Author Share Posted June 21, 2006 [!--quoteo(post=386525:date=Jun 21 2006, 02:31 PM:name=Buyocat)--][div class=\'quotetop\']QUOTE(Buyocat @ Jun 21 2006, 02:31 PM) [snapback]386525[/snapback][/div][div class=\'quotemain\'][!--quotec--]You would need a way to track users, that is either through a cookie or through a database. Once that is decided then you can simply create an array in the cookie with the links visited and when the page is loaded it checks that array and adds anchors accordingly. Otherwise if you want to use a database you would have it query for a user and links visited then act accordingly after that. I think both have their advantages; the cookie method is much much easier but also can be undone by deleting cookies. The user method is more complicated but also more permanent.[/quote]I was hoping there would be an easier way to do that, like a function but I guess that's the only way.Thanks for the solution! Quote Link to comment https://forums.phpfreaks.com/topic/12483-visited-links/#findComment-48211 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.