Skip to content
Advertisement

How to create a simple form on my website (cPanel based) that only activates during certain periods?

I have a weekly conference and I would like to log which participants are attending. I have a website I own I would like them to go to, then put in their name and click “Enter“. Afterwards, I’d like for it to save into a database on my website. I currently have cPanel behind my website.

I would like the form to ONLY activate, say, on Thursdays from 10 am to 12 pm. After that, I would like it to close up and not allow entires.

Is there a simple way to do this time exclusion and sample scripts I can find online? Thank you!

Advertisement

Answer

PHP date function would work well for this.

// get day and hour
$day = date("l");
$hour = date("h");

if($day == "Thursday") { // make sure day is right
  if($hour > "10" && $hour < "24") { // make sure hour is right
   echo "print form";
  }
}

Keep in mind that date() returns a string value that is given from timestamp()

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement