Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <?php
  2. include("db.php");
  3. session_start();
  4. if(isset($_SESSION['login_user'])){
  5. header("Location: welcome.php");
  6. }
  7.  
  8. $error = '';
  9. if (isset($_POST['submit'])) {
  10. if (empty($_POST['username']) or empty($_POST['password'])) {
  11. $error = "Please enter your login details";
  12. } else {
  13.  
  14. $username = mysqli_real_escape_string($conn, $_POST['username']);
  15. $password = md5($_POST['password']);
  16.  
  17.  
  18.  
  19. $query = mysqli_prepare($conn, "SELECT password FROM workers WHERE user_name=?");
  20. mysqli_stmt_bind_param($query,"s",$username);
  21. mysqli_stmt_execute($query);
  22. mysqli_stmt_bind_result($query,$pass);
  23. if(mysqli_stmt_fetch($query)){
  24. if ($password == $pass){
  25. header('Location:welcome.php');
  26. $_SESSION['login_user'] = $username;
  27.  
  28. }else {
  29. $error = "You typed the wrong password";
  30. unset($username, $password);
  31. }
  32. }else{
  33. $error = "User Login doesn't exists";
  34. unset($username,$password);
  35. }
  36.  
  37. }
  38. }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement