Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ?>
- <!DOCTYPE html>
- <html lang="sv">
- <head>
- <meta charset="utf-8" />
- <title></title>
- <link rel="stylesheet" href="">
- </head>
- <body>
- <?php
- $inloggad = false;
- if(isset($_POST["user"]) && isset($_POST["pass"])) {
- $user = $_POST["user"];
- $pass = $_POST["pass"];
- $user = trim($user);
- $pass = trim($pass);
- $user = strtolower($user);
- $pass = strtolower($pass);
- /* $fil = fopen("C:/xampp/htdocs/users.txt", "r") or die("Kunde inte öppna fil");
- if ($fil) {
- while (($rad = fgets($fil, 4096)) !== false) {
- $rad = trim($rad);
- $ord = explode(':', $rad);
- if($user == $ord[0] && password_verify($pass, $ord[1])){
- echo "<p>Du är nu inloggad!</p>";
- $inloggad = true;
- }
- }
- if (!feof($fil)) {
- echo "Error: unexpected fgets() fail\n";
- }
- fclose($fil);
- }*/
- $rader = file("C:/xampp/htdocs/users.txt" , "r");
- foreach ($rader as $rad) {
- }
- }
- if (!$inloggad ){
- if (isset($user) && isset($pass)) {
- echo "<h1>Fel användarnamn eller lösenord! Försök igen.</h1>";
- }
- ?>
- <form method="post">
- <h2>Logga In</h2>
- <label>Username: </label>
- <input type="text" name="user">
- <br>
- <label>Password: </label>
- <input type="password" name="pass">
- <br>
- <input type="submit">
- </form>
- <?php
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement