vendredi 29 octobre 2021

display alert if data insert late before certain day of the week

i need help. i create a system which the user need to fill in a form, but the form will only be accept if they apply it 2 days before wednesday everyweek.

this what i got so far.

$dateNow = date('Y-m-d');
if (isset($_POST['submit'])) {
      $user_id = $_POST['user_id'];
      $user_name = $_POST['user_name'];
      $position = $_POST['position'];
      $dept_code = $_POST['dept_code'];
      $dept = $_POST['dept'];
      $dept_div = $_POST['dept_div'];
      $created_dt = date('Y-m-d G:i:sa');
                
      $sql = "INSERT INTO ot_application(user_id, user_name, position, dept_code, dept, dept_div, apply_date, created_dt) VALUES ('$user_id','$user_name','$position','$dept_code','$dept','$dept_div','$dateNow','$created_dt')";

      if (mysqli_query($conn, $sql)) {
          echo "<script>alert('Borang telah dikemaskini! ')</script>";
          echo "<script>";
          echo "window.location.href = 'list_borang_kerani.php?user_id=$user_id'";
          echo "</script>";
      } else {
          echo "Error: " . $sql . "<br>" . mysqli_error($dbconfig);
      }

Aucun commentaire:

Enregistrer un commentaire