i need code for count number of times clicked the button

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
qumar
Forum Commoner
Posts: 29
Joined: Wed Nov 01, 2006 8:20 am

i need code for count number of times clicked the button

Post by qumar »

hi,
i need code for count number of times clicked the button. Please help to me.

Thanks.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

The button (if any) would be displayed at the client-side and thus it's impossible to handle that event at the server-side...

Now, if you made sure that the button click would lead to a http post/get requrest... then you could handle that request..

The logic for a counter is pretty simple: new value = old value + 1. So i wonder, what exactly are you having problems with?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: i need code for count number of times clicked the button

Post by califdon »

qumar wrote:hi,
i need code for count number of times clicked the button. Please help to me.

Thanks.
You may want to do this in Javascript, which executes in the browser, where the button is being clicked. PHP is interpreted by the server BEFORE anything is sent to the browser.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

timvw wrote:The button (if any) would be displayed at the client-side and thus it's impossible to handle that event at the server-side...
Ajax is pretty cool, though
User avatar
Cameri
Forum Commoner
Posts: 87
Joined: Tue Apr 12, 2005 4:12 pm
Location: Santo Domingo, Dominican Republic

Re: i need code for count number of times clicked the button

Post by Cameri »

califdon wrote:
qumar wrote:hi,
i need code for count number of times clicked the button. Please help to me.

Thanks.
You may want to do this in Javascript, which executes in the browser, where the button is being clicked. PHP is interpreted by the server BEFORE anything is sent to the browser.
Through the use of AJAX techniques, you can handle data back and forth between Javascript and PHP.
If what you are trying to accomplish can be done client-side, that is, it does not need any manipulation from the server, you can just leave it with Javascript, if not, you'll have to fly into the magical world of AJAX.

What is it that you are trying to do?
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Why don't you just disable the button after it has been clicked.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

If this is for security in form processing prevention, I would suggest a dual-validation format where you use Javascript on the client and PHP on the server. I'd do it this way because 1) some users disable javascript in their browsers which renders client side validation moot, and 2) it is possible to download your form to their local machine, manipulate it to be what they want and submit it. If it is not checked on the server, you could be hosed.
Post Reply