Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <?php
  2. include_once('resources/db.php');
  3.  
  4. $query = $dbh->prepare('select username, password from users where username = ? and password = ? ');
  5. $query->execute(array($_POST['username'],$_POST['password']));
  6.  
  7.  
  8. if ( isset( $_POST['submit'] )) {
  9. $username = $_POST['username'];
  10. $password = $_POST['password'];
  11.  
  12. if ( password_verify($password, $saved_password)) {
  13. if ($query->rowCount() == 1){
  14. echo "chrisschotman is ingelogd";
  15. } else {
  16. echo "<script type="text/javascript">alert('Wrong username!')</script>";
  17. }
  18. } else {
  19. echo "<script type="text/javascript">alert('Wrong password or username!')</script>";
  20. }
  21. }
  22. ?>
  23.  
  24. <form action="" method="post">
  25. <input type="text" placeholder="username" name="username"maxlength="24"><br>
  26. <input type="password" placeholder="password" name="password" minlength="8"
  27. maxlength="16"><br>
  28. <input type="submit" value="login" name="submit">
  29. </form>
  30.  
  31. <?php
  32. if (isset($_POST)) {
  33. include_once('resources/db.php');
  34. // var_dump($_POST);
  35. $query = $dbh->prepare('insert into `users`(`username`, `password`) values(?, ?)');
  36. $username = $_POST['username'];
  37. $password = $_POST['password'];
  38.  
  39. // Create salted password
  40. $hash_password = password_hash($password, PASSWORD_DEFAULT);
  41.  
  42. $query->execute(array($username, $hash_password));
  43.  
  44. $query = $dbh->prepare('select * from `users`');
  45. $query->execute();
  46. }
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement