Current location: Hot Scripts Forums » General Community » Script Requests » tracking and redirect

tracking and redirect

Reply
  #1 (permalink)  
Old 07-09-09, 02:22 PM
brennro brennro is offline
New Member
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
tracking and redirect

I'm kinda a newbie here but I am looking for a script or atleast some advice on how to accomplish the following:

When someone visits a certain URL I would like to keep track of the number of the visit and if it falls on the nth time then they get redirected.

example: Every 5th user to the URL gets redirected to another page.

Sorry if this is in the wrong forum section.

-brennro
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-09-09, 02:31 PM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 273
Thanks: 3
Thanked 5 Times in 5 Posts
You could use a simple PHP script, here is a very simple one that would work.
PHP Code:
<?php
$myFile 
"count.txt";
$fh fopen($myFile'r');
$The_Count fread($fhfilesize($myFile));
fclose($fh);

If (
$The_Count!="5"){
                                            
$The_Count=$The_Count+1;
                                            
$myFile "count.txt";
                                            
$fh fopen($myFile'w') or die("can't open file");
                                            
fwrite($fh$The_Count);
                                           
fclose($fh);
}else{
$The_Count=0;
$myFile "count.txt";
$fh fopen($myFile'w') or die("can't open file");
fwrite($fh$The_Count);
fclose($fh);
header("Location: lpagehere.html");
}
?>
Sorry dont know how to highlight the PHP code on this forum.

Last edited by Nico; 07-10-09 at 03:54 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-10-09, 03:54 AM
Nico's Avatar
Nico Nico is online now
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 7,535
Thanks: 5
Thanked 17 Times in 16 Posts
Quote:
Originally Posted by ruteckycs View Post
Sorry dont know how to highlight the PHP code on this forum.
Take a look at this page:

http://www.hotscripts.com/forums/misc.php?do=bbcode#php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 06:59 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.