0

I have to create a form that can be enabled and disabled by the admin, In my case the admin enable the form for two months per year(to be filled by users) a sort of survey.

The admin provide start date and end date ,if the Current date is in the periode given the form is enabled for all of users else a message “form unavailable”appears.

The form contain a lot of information ,those data will be stored in the database on multiple tables.

How can I do that programmatically?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Julie
  • 563
  • 6
  • 10
  • 23

1 Answers1

0

There are different methods for doing what you want. One way is to access the current timestamp using the time() function and running it through an if statement for checking the set dates,

<?php
$sDate = 1494354600;
$eDate = 1499625000;
$cDate = time();
if($cDate>$sDate&&$cDate<$eDate){
   <Form code here>
}
else{
   echo "Form Unavailable";
}
?>

sDate is the timestamp of date from which the form will be available, eDate is the date till which form will be available and cDate is the current date.

This code will make the form available from 10/05/2017 to 10/07/2017 [DD/MM/YYYY].

You can convert date to timestamp by using some website which you can find in a Google search.

Hope this helped.

Ronald P Mathews
  • 2,178
  • 1
  • 22
  • 26