Advertisement
Guest User

Untitled

a guest
Jun 26th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.81 KB | None | 0 0
  1. <?php
  2. include_once 'db.php';
  3.  
  4. if (isset($_POST['login'])) {
  5.     $username = $_POST['username'];
  6.     $password = $_POST['password'];
  7.     echo $username;
  8.     echo $password;
  9.     $query = "select * from login where username = '$username' and password='$password'";
  10.     $result = mysqli_query($connection, $query);
  11.  
  12.     $userdetails = mysqli_fetch_assoc($result);
  13.  
  14.     if($userdetails['username']=='manager')
  15.     {
  16.         header('Location: index.php?room_mang');
  17.     }
  18.     else{
  19.  
  20.         header('Location: login.php');
  21.     }
  22.  
  23.  
  24. }
  25.  
  26. if (isset($_POST['submit'])) {
  27.  
  28.     $emp_id = $_POST['emp_id'];
  29.     $first_name = $_POST['first_name'];
  30.     $last_name = $_POST['last_name'];
  31.     $staff_type_id = $_POST['staff_type_id'];
  32.     $shift_id= $_POST['shift_id'];
  33.     $id_card_type = $_POST['id_card_type'];
  34.     $id_card_no = $_POST['id_card_no'];
  35.     $address = $_POST['address'];
  36.     $contact_no = $_POST['contact_no'];
  37.     $joining_date = strtotime($_POST['joining_date']);
  38.  
  39.     $salary = $_POST['salary'];
  40.  
  41.     $query="UPDATE staff
  42. SET emp_name='$first_name $last_name', staff_type_id='$staff_type_id', shift_id='$shift_id', id_card_type=$id_card_type,
  43. id_card_no='$id_card_no',address='$address',contact_no='$contact_no',joining_date='$joining_date',salary='$salary'
  44. WHERE emp_id=$emp_id ";
  45. //echo $query;
  46.     if (mysqli_query($connection, $query)) {
  47.         header('Location: index.php?staff_mang');
  48.     } else {
  49.         echo "Error updating record: " . mysqli_error($conn);
  50.     }
  51.  
  52.  
  53. }
  54.  
  55. if (isset($_GET['empid'])!="")
  56. {
  57.    $emp_id=$_GET['empid'];
  58.     $deleteQuery = "DELETE FROM staff WHERE emp_id=$emp_id";
  59.     if (mysqli_query($connection, $deleteQuery)) {
  60.         header('Location: index.php?staff_mang');
  61.     } else {
  62.         echo "Error updating record: " . mysqli_error($connection);
  63.     }
  64. }
  65.  
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement