0

Hi to all.

Can anyone help me with this? I have PHP script the save record. But I want to have time limit in saving the record. When the local time is 4:00 PM, the user can no longer save their record. Please help.

Here's my code;

if($_POST=="Save")
{
$name = $_POST;
$age = $_POST;
$addr = $_POST;

//if time is beyond 4:00 PM this code is enable ------ this what i want.
mysql_query("insert into file(name,age,address) values ('$name','$age','$addr')");
echo "Record Save";

//if time is exceed 4:00 PM this code is enable and disable the saving codes
echo "Can not save record. Time limit has expire"

}

3
Contributors
8
Replies
10
Views
6 Years
Discussion Span
Last Post by lyrico
0
$hour = strftime('%H'); // 00-23
if ($hour >= 16) 
{
  echo "Can not save record. Time limit has expire";
}
else
{
  mysql_query("insert into file(name,age,address) values ('$name','$age','$addr')");
  echo "Record Save";
}
0
if (date('H') >= 16:00 ){
    if($_POST['submit']=="Save")
    {
      $name = $_POST['name'];
      $age = $_POST['age'];
      $addr = $_POST['addr'];
      if(mysql_query("insert into file(name,age,address)                  
            values  ('$name','$age','$addr')"))
         echo "Record Save";
      else
         echo "Error in Insert query";
   }
}else{
   echo "Time exceeded, You cannot insert into database. Try, again.";
}

Edited by mike_2000_17: Fixed formatting

0

how about the system accept is exactly until 4:00 PM only. but if the time is 4:01 PM, the system doest save the record?

and another one, how can i write the code that appear as same as pritaeas code?

thanks a lot guys.

0

You can use [ code ] tags.

$time = strftime('%H%M%S');
if ($time > 160000) 
{
  echo "Can not save record. Time limit has expired";
}
else
{
  mysql_query("insert into file (name, age, address) values ('$name', '$age', '$addr')");
  echo "Record Saved";
}

Edited by pritaeas: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.