Jump to content

Recommended Posts

Here is the problem I need to solve.. I have several links out from my index page and I need to track how many times visitors have clicked those links, then display that number on my index page by the link.

 

I am thinking that the easiest way to track the hits out is to send the link to a page on my site which redirects to the page I want the link to go to.  The part that I don't know how to do is keeping count of how many times that has happened, and then printing that number/variable back on my index page.

 

I'm still learning php and any help with this would be greatly appreciated.

You will either need to use files (not recommend) or a MySQL database (recommended).

 

For files look into: fopen, fwrite and fclose.

 

The script you create will be something like "linkout.php" then the links on the page would be "linkout.php?id=4" etc.

Ok so say my link is linkout.php?cat=3&item=5

 

My php on the linkout.php would do something like ++ to the variable in the mySQL database equal to catagory 3 item 5.

 

My index page would echo the variable for cat 3 item 5.

 

Does that sound right?

 

Also, what is the most accepted form of redirect?

I am having trouble with this; I can't redirect the page with header('location:') because it is saying Warning: Cannot modify header information - headers already sent by X in Y.php on line 6

 

Is there a way to redirect after I insert the data into the database?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.