Jump to content

Page redirect after 'X' amount of clicks


nicobach1

Recommended Posts

There are a couple ways of achieving this.  One method would be that all links are redirect links, and you use session variables to determine number of clicks.  Then in the redirect, if it shouldn't redirect again (based off of session variable check) just send to initial link, otherwise redirect to new link.

 

There isn't a straight simple answer for this one, some digging and understanding of php methods (and javascript most likely) will be required.

p2grace,

 

I have been  searching for some sort of code pretty much all day and i just cant seem to find anything, if you could point me to a site the explains how to do what im looking for i would greatly appreciate it since i really need this done soon! thanks

There are a couple ways of achieving this.  One method would be that all links are redirect links, and you use session variables to determine number of clicks.  Then in the redirect, if it shouldn't redirect again (based off of session variable check) just send to initial link, otherwise redirect to new link.

 

There isn't a straight simple answer for this one, some digging and understanding of php methods (and javascript most likely) will be required.

 

Very easy way.

 

Set a cookie then if $_COOK['xxx'] > 5

 

header(Location: bla bla);

There are a couple ways of achieving this.  One method would be that all links are redirect links, and you use session variables to determine number of clicks.  Then in the redirect, if it shouldn't redirect again (based off of session variable check) just send to initial link, otherwise redirect to new link.

 

There isn't a straight simple answer for this one, some digging and understanding of php methods (and javascript most likely) will be required.

 

Very easy way.

 

Set a cookie then if $_COOK['xxx'] > 5

 

header(Location: bla bla);

 

This could work, however if a user refreshes their page this will also redirect, and this assumes the content is templatized.  You also wouldn't be able to track to which link they are referring from if that data was necessary.  Also, I wouldn't recommend using cookies for this, but rather sessions that way you can use multi-dimensional arrays.

if i use cookies wouldn't that be for each visitor and not for everyone visiting my site? Would i be able to use a text file or database that would track how often a certain link has been clicked, and if it has been clicked more than five times, then redirect to a certain page? and if that is possible, again i would need help in order to accomplish this since my knowledge of php and sql is very small.

You would use cookies if you want the redirects to be remembered throughout each visit.  As far as tracking goes, a database would be the best option.  Like I said before, you'll need to do some research and googling to learn the information you need.  The link below demonstrates how to connect to a mysql database (assuming you have one created).

 

http://www.siteground.com/tutorials/php-mysql/php_mysql_connection.htm

would you be able to provide me with the php code on how it would track how many times a link has been clicked, since i really don't know where to begin. I think that i would use the

header("Location: location.php")

code to specifiy what page to redirect to after 5 clicks, but im not even sure about that. Like i said, i know very very little about php. I really appreciative any help you can offer. thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.