PageRenderTime 58ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/assign.php

https://bitbucket.org/d3bugg3r/shiftsystem
PHP | 19 lines | 18 code | 0 blank | 1 comment | 3 complexity | 8f293056a704e033fa24b195c9ce67df MD5 | raw file
  1. <? if ($_SESSION['logged_in'] != true) {
  2. echo "There has been an error, please go back and try again";
  3. die();
  4. }
  5. $return = escape($_POST['return']);
  6. $shift = escape($_POST['id']);
  7. $c_user = escape($_POST['c_id']);
  8. //check to see if shift is in the past
  9. $r = mysql_query("SELECT * FROM hours WHERE id='$shift'");
  10. $r = mysql_fetch_array($r);
  11. $str = "$r[3]-$r[2]-$r[1]"; //get the date of the shift
  12. $shift_date = strtotime($str);
  13. if (time() > $shift_date) {
  14. echo "You cannot edit shifts that are in the past, redirecting...";
  15. echo "<META HTTP-EQUIV='Refresh' Content='1; URL=index.php?page=cal&$return'>";
  16. die();
  17. }
  18. mysql_query("UPDATE hours SET worker='$c_user' WHERE id='$shift'");
  19. echo "<META HTTP-EQUIV='Refresh' Content='0; URL=index.php?page=cal&$return'>";