PHP Page Counter Then Redirect User to Different URL
Posted on 2011-04-25
I need to run some tests to make sure a banner ad is tracking properly. I'd like to set up a page that, if visited, writes to a file and then redirects the user to a new URL (without the user noticing anything). I have this php file:
header( "HTTP/1.1 301 Moved Permanently" );
header( "Status: 301 Moved Permanently" );
header( "Location: http://www.domain.com/" );
exit(0); // This is Optional but suggested, to avoid any accidental output
/*script for reading the text file*/
/*script for adding 1 to the file*/
And a file called "count.txt" to write to in the same directory as the count.php file (with permissions set properly). When I type in the URL of count.php it redirects properly to domain.com, but the text file always shows "1". It doesn't seem to increase the count. This has to be something terribly stupid on my part.
Might anyone have an idea on how I can remedy this and get it to work right? I just need to see a simple page view count in the text file for comparison purposes.