Forum Moderators: coopster

Message Too Old, No Replies

Counting number of times submit is clicked

         

Shaman13

4:00 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



Does anyone know how to keep track of how many times a form is submitted by tracking clicks of the submit button. I know you can do it in Java but I was wondering if one of the hot shots on this forum had found a way to do it with Php. The idea behind it is I want to create a form where if the submit button is clicked the first time it saves the record to the database. If the user clicks more than once the record which was added is updated. Nothing against Java but I would really love to keep the app purely Php. As always, I really appreciate all the great help this forum affords. I am new to Php but I have used many forums and this is one of the best if not the best for getting straight answers to tough questions. Thanks Much and have a great day.

jatar_k

6:05 pm on Mar 1, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't think you necessarily need to count, though you could count it using a session. Store the number of times it has been submitted and then some other identifiable information to know what row to update.

I would think that if there is some sort of identifiable information you could just use that to check if they have already submitted the form, then update or insert as required.

dmmh

7:45 am on Mar 2, 2005 (gmt 0)

10+ Year Member



a bit different, but I think this thread might give you some ideas:

[webmasterworld.com...]

grandpa

7:53 am on Mar 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If the form is submitting to the same page <form name="CONTINUE" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">, you could add another hidden field to the post, and then retrieve that field from the POST array and add 1 each time the form is submitted.

I'm not sure I would do this to determine if a record should be INSERT or UPDATE. For that I'd say it always good policy to check with the db first.

incywincy

8:43 am on Mar 2, 2005 (gmt 0)

10+ Year Member



This may be a little over the top but you could record the visitor IP as part of your database record. If the IP already exists within a certain time period then update the record otherwise insert the record. Recording contacts in this way makes it easy for you to track their surfing behaviour on your site as well.