Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 23rd, 2004, 07:43 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
Default Click Counting

Good morning

is there anyway that we can know how many people for example click in our homepage?

(I have link that is for the stream (.ram) and i want to know how many people click on that link.)

Thanks
Regards
Mani

 
Old December 24th, 2004, 12:16 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Instead of linking directly to the .ram file you should link to a php page in a way like this:

http://www.yoursite.com/dir/counter.php?file=stream.ram

Have the PHP file check if a file exists called $_GET['file'].".txt" and if it doesn't, create it with the number "1" in it (to show that the stream has been clicked once). If $_GET['file'].".txt" does exist, have it get the number inside, increment it, and save the file.

hth,

-Snib - http://www.snibworks.com
Where will you be in 100 years?
 
Old December 24th, 2004, 12:17 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Also don't forget to redirect the user to the file!

header("Location: ".$_GET['file']);

-Snib - http://www.snibworks.com
Where will you be in 100 years?
 
Old December 24th, 2004, 03:13 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hi Snib - Merry Xmass to all

in your example you told me to check the file if it exists. i did not understand the .txt part.
(that means i store the name of the stream files in my mysql database so is not it better to check on my database)

Thanks
Regards
Mani



 
Old December 25th, 2004, 11:04 AM
Authorized User
 
Join Date: Dec 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to colin.horne
Default

I think Snib is suggesting using using the .txt file as a counter (the file that stores the number of hits a file has got).

Eg: To store the number of times someone plays snowball.ram, make a file called snowball.ram.txt which counts the number of times people play snowball.ram.

Just make sure you have an "allowed files" array, containing all the files that people are allowed to download otherwise people could do something like this: ...?file=/etc/passwd, which would create a file called /etc/passwd.txt. They wouldn't be able to *see* the /etc/passwd file, but they could make loads of annoying text files all over your filesystem (this is of course depending on what privileges php is running with - php would probably not be able to write in the .etc folder, it was just the first file that came to mind).

Cheers

--
Please contact me at:
Colin (dot) Horne (at) gmail (dot) com
 
Old December 25th, 2004, 01:33 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Thanks



Thanks
Regards
Mani_he






Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting pixels shanthi85 VB How-To 0 May 22nd, 2007 02:13 AM
Error in Counting Jonas Access VBA 2 August 15th, 2006 12:21 AM
Right-Click or Double-Click Combobox? panuvin C# 2005 3 June 15th, 2006 04:30 PM
charachter counting bjackman Access 12 March 11th, 2005 04:51 AM
Counting ?!? hcweb Classic ASP Basics 2 December 8th, 2003 05:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.