Form timer in php

I want the form to be submitted at least 15 seconds after the page loads (because this is how long it takes on average to fill out the form).

I know that I can do something like $ time_page_loaded = time () on top;

if (time() < $time_page_loaded + 15)
{
  // show reCaptcha
}
else
{
  // submit to database
}

It is right? Also, when you re-remember this in a function, how would you do it?

+3
source share
4 answers

, , ​​. () (, / ) .. , , , .

, HAS , , , ( ) - , .

javascript ( ). javascript . "onsubmit" . , , recaptcha .

0

, , .

- , cookie.

script :

<?php
session_start();

, , :

if (time() < $_SESSION["time_page_loaded"] + 15)
{
    // Captcha
}
+2

, , <input type="hidden" value="<?php echo time(); ?>" /> ( ) time() . , , .

, , , . , (IE ), - "". jQuery, :

http://www.erichynds.com/jquery/a-new-and-improved-jquery-idle-timeout-plugin/

-1

( PHP), ,

BUT it is not safe. You should use something like javascript to do this

-2
source

Source: https://habr.com/ru/post/1788693/


All Articles