Guest User

Untitled

a guest
May 31st, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2. if(!empty($_POST))
  3. {
  4. require(api.php);
  5.  
  6. connect();
  7.  
  8. $username=$_POST["username"];
  9. $password=$_POST["password"];
  10.  
  11. $sql = "SELECT password, salt FROM users WHERE username='".$username."'";
  12.  
  13. $result = mysql_query($sql);
  14. if(!$result)
  15. {
  16. die("<i>login.php: </i>Kunde inte köra fråga: ".mysql_error());
  17. }
  18.  
  19. $entry = mysql_fetch_assoc($result);
  20.  
  21.  
  22.  
  23. $hashedPassword = sha1($entry["salt"].$password.$username);
  24. if ($username == $entry["username"] && $hashedPassword == $entry["password"])
  25. {
  26. session_start();
  27. $_SESSION["username"] = $username;
  28. $_SESSION["password"] = $hashedPassword;
  29. header("Location: customers.php");
  30. }
  31. else
  32. {
  33. header("Location: index.php");
  34. }
  35. }
  36. else
  37. {
  38. header("Location: index.php");
  39. //echo("<i>login.php:</i> No POST data");
  40. }
  41. // session_start();
  42. // if(!isset($_SESSION['username']))
  43. // {
  44. // header("Location: index.php");
  45. // }
  46. ?>
Add Comment
Please, Sign In to add comment