Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 822455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:48:04+00:00 2026-05-15T02:48:04+00:00

In my web page a user fill a form who send information to a

  • 0

In my web page a user fill a form who send information to a MySql database. One of the data inputs sent is a date/time, in the format date('l jS \of F Y h:i:s A');
(I can change the format as needed)

So when the user submits the form I want to check if the actual time/date is 30 seconds more than the sent time/date in order to allow or not the submission of the form. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:48:04+00:00Added an answer on May 15, 2026 at 2:48 am

    So you have something like…

    <form action="wtv.php" method="POST">
        <input type="hidden" name="date" value="<?php echo date('l jS \of F Y h:i:s A'); ?>" />
        <input type="submit" />
    </form>
    

    … and when the user clicks on ‘submit’ you want to check if the ‘date’ input’s value is from less than 30 seconds ago?

    You could do this with something like Ken Keenan suggests… but the problem is that you can’t trust the client input. In your comment on jeroen’s answer you indicate an awareness that the client scripting is untrustworthy, but that’s not limited to the scripting; if you really need this to be secure so that no one can submit this form more than 30 seconds after requesting the <form>, you have to do something else.

    The problem is that what the server expects of the “date” input is predictable; if I visit your <form> and open up Firebug or even save the HTML document and open it in notepad, I can guess pretty easily how to update the <input /> so I can submit.

    Instead use a token.

    Randomly generate a kind of unique, random ID and store it in the session or the database…

    $unique = md5(uniqid()).md5(time()); // there are better ways to get a unique random ID
    $_SESSION['tokens'][$unique] = time();
    

    Then include the token (not the date/time!) in the <form>…

    <form action="wtv.php" method="POST">
        <input type="hidden" name="token" value="<?php echo htmlentities($unique); ?>" />
        <input type="submit" />
    </form>
    

    … and on submit check that the time from that token was less than 30 seconds away.

    <?php
        // partially borrowed from Ken Keenan's answer...
        if((time() - $_SESSION['tokens'][$_POST['token']]) > 30) {
            echo "Time's up!";
        } 
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like my web page to allow the user to add data, even when
In my web page, if a user choses certain options in a form, say
When I try user = System.Web.UI.Page.CurrentUser or user = System.Web.UI.Page.User.Identity I get an error
new on rails and using windows for now,, i have web page that user
I've got a web page where the user can add a new item to
I have a list of items on my web page that the user can
Im trying to display some files in a web page so the user can
I have a web page that prompts for user input via DropDownLists in some
I have a web page that uses three controls to allow a user to
This is how my web page looks like: PosisionDataView is a web user control,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.