deurwaarder wrote:don't want to sound like a pain but: could you translate the php jargon to common english? i'm only a beginner to php so it confuses me. sorry :o
Hmm. Thought it was quite clear, and even on reflection, I don't know how to describe the process with more clarity.
Maybe some annotated but ficticious code might better, as long as you recognize this is not working code, only an illustration of the process:
Here's a ficticious line from an html display of an image embedded within an anchor that follows a url when you click on the image:
<a href="Http://www.somehost.com/PictureClickCounter.php? name=http://someurl.com/somehtm">
<img"../Photos/example.jpg" width="100" height="108">
</a>
When you click on the photo displayed in the html, you will send the url described in the href to the server, where the ClickCounter.php script resides.
Notice that the php url has tacked on to the tail end a "?". This is a marker that begins what is sometimes referred to as the query portion of a URL. It consists of a series of name=value constructs, each separated by an ampersand ('&'). In this case there is only one name value set, the word "name" and the value is a link.
Since the whole URL is attached to the message header that is sent to the server, when the php script is executed, it knows that a link has been clicked on, and it can find out where the real location is by using a statement like: "$_GET['name']" to decode the query contained in the link.
Now the script can update a counter. To make it persistant, you could most easily simply use a text file to hold a counter variable.
Than means the script should read the counter file contents into a local variable, increment it, and then write it back to the counter file.
The code may look something like this:
$count = file('CounterFile.txt'); // Read the current count from a file
$count++; //Increment the count
$fp = fopen('CounterFile.txt', 'wb'); //Clear out the old counter with a new write
$t=rtrim($count)."\n";
fwrite($fp,$t); //Write a new text line (don't forget write permissions)
fclose($fp);
After taking care of the counter, all you have to do is use the $_GET array to retrieve the URL you want to go to:
$location=$_GET['name'];
Now you can transfer to the original link that was clicked on.
Perhaps something like:
$url='Location: '.$location;
header($url); //Redirect to original link
exit();
That should do it.