Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 23rd, 2004, 06:43 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old December 24th, 2004, 11:16 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
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?
Reply With Quote
  #3 (permalink)  
Old December 24th, 2004, 11:17 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
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?
Reply With Quote
  #4 (permalink)  
Old December 24th, 2004, 02:13 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
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



Reply With Quote
  #5 (permalink)  
Old December 25th, 2004, 10:04 AM
Authorized User
 
Join Date: Dec 2004
Location: , , United Kingdom.
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
Reply With Quote
  #6 (permalink)  
Old December 25th, 2004, 12:33 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Thanks



Thanks
Regards
Mani_he

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 03:51 AM
Counting ?!? hcweb Classic ASP Basics 2 December 8th, 2003 04:08 PM



All times are GMT -4. The time now is 02:34 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.