em89

LogginForm

Jul 14th, 2014
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.44 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Loggin</title>
  5.     <link rel="stylesheet" type="text/css" href="style.css">
  6. </head>
  7. <body>
  8.     <div class="loggin">
  9.  
  10.         <form method="POST">
  11.             <label for="user">User Name:</label>
  12.             <input type="text" name="userName" id="user">
  13.             <br>
  14.             <label for="pass">Password:</label>
  15.             <input type="password" name="password" id="pass">
  16.             <br>
  17.             <a href="Profile.php"><input type="submit" name="submit" value="Submit" /></a>
  18.         </form>
  19.         <form method="POST" action="Registration.php">
  20.             <input type="submit" name="register" value="Register" />
  21.         </form>
  22.     </div>
  23.     <?php
  24.  
  25.         $userName = trim($_POST['userName']);
  26.         $userPass = trim($_POST['password']);
  27.         $string = file_get_contents('data.txt');
  28.         $string = explode("\n", $string);
  29.         $error = true;
  30.         foreach ($string as $key => $value) {
  31.             $value = explode("!", $value);
  32.                 if (($userName === $value[0]) && ($userPass === $value[1])) {
  33.                 $error = false;
  34.                 break;
  35.             }
  36.         }
  37.         if (empty($_POST['userName']) || empty($_POST['password'])) {
  38.             echo "<p>You have to fill all fields!</p>";
  39.         }
  40.         if ($error) {
  41.             echo "<p>Invalid username or password!</p>";
  42.         }
  43.        
  44.        
  45.         ?>
  46. </body>
  47. </html>
Advertisement
Add Comment
Please, Sign In to add comment