Jump to content


Photo

Visited Links


  • Please log in to reply
6 replies to this topic

#1 phileplanet

phileplanet
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 20 June 2006 - 07:35 PM

Is there a way for me to determine if a link has been visited using PHP?

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 20 June 2006 - 09:46 PM

You could probably search through your raw server logs with strpos(haystack,needle)

#3 phileplanet

phileplanet
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 21 June 2006 - 03:18 AM

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?

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 21 June 2006 - 11:00 AM

$_SERVER['HTTP_REFERER']

That variable stores the last location the user come from.

#5 phileplanet

phileplanet
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 21 June 2006 - 06:23 PM

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.

#6 Buyocat

Buyocat
  • Members
  • PipPipPip
  • Advanced Member
  • 267 posts

Posted 21 June 2006 - 06:31 PM

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.
Looking for some easy-to-use tools?  Try these, https://sourceforge....jects/utils-php -- I made them myself.  They're distinct tools which are easy to understand and use.  See some examples uses at http://www.anotherearlymorning.com

#7 phileplanet

phileplanet
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 21 June 2006 - 08:12 PM

[!--quoteo(post=386525:date=Jun 21 2006, 02:31 PM:name=Buyocat)--][div class=\'quotetop\']QUOTE(Buyocat @ Jun 21 2006, 02:31 PM) View Post[/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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users