Borvik (Programmer) (OP)
1 Dec 05 11:54
I'm working on a page counter for a user that doesn't know much about modifying html to include one properly.
It needed to be able to track multiple pages (for reporting purposes), be simple for the user, and add new page easily when necessary. The counter is not visible on the website.
The user has no knowledge of php, and shouldn't have to play with the file.
So, I came up with a solution. Have the user include the counter script as an image (which would output a 1px square image just so it outputs something), and the script would pull the name of the file via HTTP_REFERER and store it in the database (either adding, or updating the hits), with of course an admin page that allows the user to view all the pages and the number of hits.
Currently, it works fine - for grabbing the name of the file, however - the name of the file could be the same for several pages. Here's what I have so far:
$page_name = $_SERVER['HTTP_REFERER'];
$slash_idx = strrpos($page_name, "/");
$page_name = substr($page_name, $slash_idx + 1);
What I'm hoping to accomplish is to pull, not the name of the file - but the Title that the referring page has. I'm even sure if that's possible.
Any insight would be appreciated.