Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. $db = array(
  5. "username"=>"marcus", "password"=>"1234", "salt"=>"M!Kvm48nBKn!-jdhJGV@F5?"
  6. );
  7.  
  8. $user = $pdomodel->select( "username" );
  9.  
  10. $password = hash('sha512', $password . $user['0']['salt']);
  11.  
  12. if ($password == $user[0]['password']) {
  13. $_SESSION['username'] = $_POST['username'];
  14. }else {
  15. //Invalid Login
  16. echo "Bruger eller kode er forkert!";
  17. }
  18.  
  19. if(isset($_GET['logout'])) {
  20. $_SESSION['username'] = '';
  21. header('Location: ' . $_SERVER['PHP_SELF']);
  22. }
  23. echo password_hash("rasmuslerdorf", PASSWORD_DEFAULT)."\n";
  24. ?>
  25. <html>
  26. <head>
  27. <title>Sikker login</title>
  28. </head>
  29. <body>
  30. <?php if($_SESSION['username']) {
  31. include 'view/loggedin.php';
  32. }
  33. else {
  34. include 'view/loggedout.php';
  35. }
  36. ?>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement