Advertisement
Guest User

Untitled

a guest
Nov 30th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <?php
  2. ?>
  3. <!DOCTYPE html>
  4. <html lang="sv">
  5.  
  6. <head>
  7. <meta charset="utf-8" />
  8. <title></title>
  9. <link rel="stylesheet" href="">
  10. </head>
  11.  
  12. <body>
  13. <?php
  14. $inloggad = false;
  15.  
  16. if(isset($_POST["user"]) && isset($_POST["pass"])) {
  17. $user = $_POST["user"];
  18. $pass = $_POST["pass"];
  19.  
  20. $user = trim($user);
  21. $pass = trim($pass);
  22.  
  23. $user = strtolower($user);
  24. $pass = strtolower($pass);
  25.  
  26.  
  27. /* $fil = fopen("C:/xampp/htdocs/users.txt", "r") or die("Kunde inte öppna fil");
  28. if ($fil) {
  29. while (($rad = fgets($fil, 4096)) !== false) {
  30. $rad = trim($rad);
  31. $ord = explode(':', $rad);
  32. if($user == $ord[0] && password_verify($pass, $ord[1])){
  33. echo "<p>Du är nu inloggad!</p>";
  34. $inloggad = true;
  35. }
  36. }
  37. if (!feof($fil)) {
  38. echo "Error: unexpected fgets() fail\n";
  39. }
  40. fclose($fil);
  41. }*/
  42.  
  43. $rader = file("C:/xampp/htdocs/users.txt" , "r");
  44. foreach ($rader as $rad) {
  45.  
  46. }
  47.  
  48. }
  49. if (!$inloggad ){
  50. if (isset($user) && isset($pass)) {
  51. echo "<h1>Fel användarnamn eller lösenord! Försök igen.</h1>";
  52. }
  53. ?>
  54. <form method="post">
  55. <h2>Logga In</h2>
  56. <label>Username: </label>
  57. <input type="text" name="user">
  58. <br>
  59. <label>Password: </label>
  60. <input type="password" name="pass">
  61. <br>
  62. <input type="submit">
  63. </form>
  64. <?php
  65. }
  66. ?>
  67. </body>
  68. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement