Advertisement
kirkniverba

Stackoverflow | PHP Login Display Problem

Jun 10th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.50 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. $user["usernamehere"] = "passwordhere";
  5. if (!isset($_SESSION['logged_in']))
  6. {
  7.     if ($_SERVER['REQUEST_METHOD'] == 'POST')
  8.     {
  9.         if (empty($_POST['username']) || empty($_POST['password']))
  10.         {
  11.             echo '<html><body><div id="center"><h2> Login Status: <br/></h2><span style="color:red; font-weight: bold">Please fill in all fields!</span></div></body>';
  12. header("Refresh: 0;");
  13.         }
  14.         elseif ($user[$_POST['username']] != $_POST['password'])
  15.         {
  16.             echo '<div id="center"><h2> Login Status: <br/></h2><span style="color:red; font-weight: bold">Your username/password is wrong!</span></div></body>';
  17. header("Refresh: 0;");
  18.         }
  19.         else
  20.         {
  21.             $_SESSION['ingelogd'] = true;
  22.             echo '<div id="center"><h2> Login Status: <br/></h2><span style="color:green; font-weight: bold">You are now logged in!</span></div>';
  23. header("Location: /index.html");
  24.         }
  25.     }
  26.     else
  27.     {
  28.         exit('<br /><br />
  29. <link rel="stylesheet" href="/css/body.css">
  30. <link rel="stylesheet" href="/css/button.css">
  31. <div id="center">
  32.        <form method="POST" action=""><p>
  33.        Username:<br />
  34.        <input type="text" name="username" /><br /><br />
  35.        Password:<br />
  36.        <input type="password" name="password" /><br /><br />
  37.        <input type="submit" value="Login" /> <input type="reset" value="Empty fields" />
  38.        </form></div>');
  39.     }
  40. }
  41. ?>
  42. <link rel="stylesheet" href="/css/body.css">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement