The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Allow user to click button once per day!

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #178451
    David Reis

    Hi people
    Just wondering if someone could help me with this.

    I have a form that only want to show for people that clicked on the submit button more than 24 hours before. So if someone goes to the website and click on submit i will only allow them to submit again after 24 hours…

    I know that this involves cookies and all so if someone could help me to get on the right track for this it would be great!!!

    thanks in advance

    David Reis

    Thanks Soronbe

    Im not using a database by the way. is just a php script that will stay live for a short period of time so i dont mind to have just a temporary solution for it.


    David Reis

    Do you know any solutions for this?


    You could use PHP’s file system to write a simple text file that can serve as a mini database.

    In PHP you can read text files using file($name_of_file); which returns an array for you.

    So if the file contained IP addressed.

    Let’s say example.txt contains these three lines:


    If you do print_r( file( 'example.txt' ) );

    You’ll get an array of:

      [0] => 12.10.100
      [1] => 12.11.200
      [2] => 12.12.300

    Then before the form loads, you can check if IP is present in the array and handle it appropriately. If not, then write functionality that once the user submits form, add their IP to the file.

    To check for value you could use PHP’s in_array(); function.

    Hope that helps.


    I agree with Alen. Create a text file on the server and save the IP address of the people who submit the form and check the list when the user tries to submit.
    You’ll also have to save the time the user submitted the form so if they’re over the 24 hour period it will reset the timer


    Keep in mind that IP addresses almost never correspond 1:1 to a particular person. Hundreds of people might be assigned the same dynamic IP address by their ISP; one person might have a different IP address for each of a dozen consecutive requests. And that’s normal: not even considering someone who is trying to circumvent your checks.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.