Advertisement
Guest User

Untitled

a guest
Oct 6th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <form class="" action="" method="post">
  2.  
  3. <?php login_user();?>
  4.  
  5. <div class="form-group"><label for="">
  6. username<input type="text" name="username" class="form-control"></label>
  7. </div>
  8.  
  9. <div class="form-group"><label for="password">
  10. Password<input type="text" name="password" class="form-control"></label>
  11. </div>
  12.  
  13. <div class="form-group">
  14. <input type="submit" name="submit" class="btn btn-primary" >
  15. </div>
  16.  
  17. </form>
  18.  
  19. function login_user(){
  20.  
  21. if(isset($_POST['submit'])) {
  22.  
  23. $username = $_POST['username'];
  24. $password = $_POST['password'];
  25.  
  26. $sqlQuery = "SELECT * FROM users WHERE username = \'{username\}' AND password = \'{password\}'";
  27. $statement = $db->prepare($sqlQuery);
  28. $statement->execute($username, $password);
  29. $data = $statement->fetch();
  30. if($data){
  31. header("location:admin");
  32. }else {
  33. header("location:login.php");
  34. }
  35.  
  36.  
  37.  
  38.  
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement