Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. $connect = new PDO('mysql:host=localhost;dbname=login', 'root', '');
  5.  
  6. if(isset($_POST['login'])){
  7. $username = $_POST['username'];
  8. $password = $_POST['password'];
  9.  
  10. $query = $connect -> prepare("SELECT COUNT('id') FORM 'users' WHERE 'username' = '$username' AND 'password' = '$password'");
  11. $query -> execute();
  12.  
  13. $count = $query->fetchColumn();
  14.  
  15. if($count == "1"){
  16. $_SESSION['username'] = $username;
  17.  
  18. header('location: login.php');
  19. }else{
  20. header('location: index.php');
  21. }
  22. }
  23.  
  24. ?>
  25.  
  26.  
  27. <form method="POST" action="" name="login">
  28. <input type="text" name="username">
  29. <input type="password" name="password">
  30. <input type="submit" name="login">
  31.  
  32.  
  33. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement