Advertisement
Guest User

Untitled

a guest
Nov 10th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.49 KB | None | 0 0
  1. <!DOCTYPE html>
  2.     <html lang="en">
  3. <head>
  4. <title>loggin in tutorial</title>
  5.     <meta charset="utf-8" />
  6.     <link href='http://fonts.googleapis.com/css?family=questrial' rel='stylesheet' type='text/css'>
  7. </head>
  8. <body>
  9. <div class="header">
  10. <nav class="row">
  11. <div id ="logo">
  12. </div>
  13. </div>
  14. <hr></hr>
  15. <div id="login">
  16. <form action="index.php" method="post">
  17.     <th>Username:<input type="text" name="username" placeholder="Username"></th>
  18.     <th>Password:<input type="password" name="password" placeholder="Password"></th>
  19.     <input type="submit" value="login">
  20.     </form>
  21. </div>
  22.     </body>
  23. </html>
  24. <?php
  25.    
  26.     if (empty($_POST) === false) {
  27.         $username = $_POST['username'];
  28.         $password = $_POST['password'];
  29.         // error checking
  30.        
  31.         if (empty($username) == true || empty($password) == true) {
  32.             $errors[] = 'You need to enter a username and password';
  33.             header("location: login.php");
  34.         } else
  35.         if (user_exists($username) == false) {
  36.             $errors[] = 'Username does not exist';
  37.             header("location: login.php");
  38.         } else {
  39.             // call login function with submitted data
  40.             $login = login($username, $password);
  41.            
  42.             if ($login == false) {
  43.                 $errors[] = 'Username and password combination is incorrect';
  44.                 header("location: login.php");
  45.             } else {
  46.                 // set the user session and login
  47.                 $_SESSION['username'] = $login;
  48.                 header('Location: index.php');
  49.                 exit();
  50.             }
  51.  
  52.         }
  53.  
  54.     } else {
  55.         $errors[] = 'No data recieved';
  56.     }
  57.  
  58.     // Output
  59.    
  60.     if (empty($errors) == false) {
  61.     }
  62.  
  63.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement