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"

}

$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";
}
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.";
}

Thanks for the reply guys. I really appreciated that.

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.

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";
}

thanks again pritaeas

Forgot... you need to close the tag with [ /code ] too.

just want to make a sample ^^,

<?php
echo "sample";
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.