Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. <?php
  2. function loginUser() {
  3.     global $connection;
  4.  
  5.     $username = $_POST['username'];
  6.     $password = $_POST['password'];
  7.  
  8.     $query = "SELECT * FROM users WHERE userName = '$username' AND userPassword = '$password' ";
  9.  
  10.     $result = mysqli_query($connection, $query);
  11.  
  12.  
  13. } ?>
  14.  
  15. <!DOCTYPE html>
  16. <html lang="en">
  17. <head>
  18.     <meta charset="UTF-8">
  19.     <title>Document</title>
  20.     <!-- Latest compiled and minified CSS -->
  21. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  22.  
  23. </head>
  24. <body>
  25.  
  26. <?php if(isset($_POST['submit'])){ loginUser(); } ?>
  27.  
  28.     <?php if(!$result){ ?>
  29.  
  30.         <div class="container">
  31.         <?php echo "<h3 style='color: red;'>Username / Password not found</h3>"; ?>
  32.         </div>
  33.    
  34.         <?php } else { $row = mysqli_fetch_assoc($result); ?>
  35.  
  36.         <div class="container">
  37.         <?php echo "<h3 style='color: green;'>Welcome back " . $row['firstName'] . " " . $row['lastName'] . "</h3>"; ?>
  38.         </div>
  39.     <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement