Link counter / Redirection
Posted: Wed Jun 05, 2002 12:08 pm
Hi folks,
I am trying to set up a links page on my site with a counter that tracks how many times an external link has been followed, and then sort the page with the most popular link at the top (I sure you've all seen this kind of thing!).
I have two files. The link page generator which sorts the links in "hit" order. This is no problem.
When a link is followed the user is taken to link_redirect.php?url=http://www.somewhere.web. The link_redirect.php page extracts the url from the address line, increases the number of hits and writes the new value to the db.
Then the user needs to be taken to the link they have followed, and thats where I need your help.
I have seen something to do with sending headers for redirection, but as I'm new to PHP I am not ready for it!
The scripts were originally written in ASP as I know a little bit more about it. I used Response.Redirect(link) at the end of the script so this was activated when updating the db had been done.
Is this solvable? If I use META redirection how do I know what time to set to give the script long enough to update the db, but not too long that the user is looking at a blank page?
Thanks.
I am trying to set up a links page on my site with a counter that tracks how many times an external link has been followed, and then sort the page with the most popular link at the top (I sure you've all seen this kind of thing!).
I have two files. The link page generator which sorts the links in "hit" order. This is no problem.
When a link is followed the user is taken to link_redirect.php?url=http://www.somewhere.web. The link_redirect.php page extracts the url from the address line, increases the number of hits and writes the new value to the db.
Then the user needs to be taken to the link they have followed, and thats where I need your help.
I have seen something to do with sending headers for redirection, but as I'm new to PHP I am not ready for it!
The scripts were originally written in ASP as I know a little bit more about it. I used Response.Redirect(link) at the end of the script so this was activated when updating the db had been done.
Is this solvable? If I use META redirection how do I know what time to set to give the script long enough to update the db, but not too long that the user is looking at a blank page?
Thanks.