Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include 'database.php';
- // Retrieve username and password from database according to user's input
- $username=mysqli_real_escape_string($connect,$_POST['username']);
- $password=mysqli_real_escape_string($connect,$_POST['password']);
- $encrypted_mypassword=md5($password);
- $sql = "SELECT * FROM staffdetail WHERE (username = '$username') and (password = '$encrypted_mypassword')";
- $login = mysqli_query($connect,$sql);
- $count = mysqli_num_rows($login) ;
- // Check username and password match
- while($row = mysqli_fetch_assoc($login)){
- $_SESSION['roleid'] = $row['idrole'];
- $_SESSION['employeeid'] = $row['id'];
- $type = $_SESSION['roleid'];
- }
- if ($count != "") {
- switch ($type) {
- case 1:
- header('Location: ../technician/index.php'); // admin Level;
- break;
- case 2:
- header('Location: ../clerk/index.php');
- break;
- case 2:
- header('Location: ../director/index.php');
- break;
- }
- }
- else {
- Print'<script>alert(Incorrect username or password !");</script>';
- Print'<script>window.location.assign("login.php");</script>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement