Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once('resources/db.php');
- $query = $dbh->prepare('select username, password from users where username = ? and password = ? ');
- $query->execute(array($_POST['username'],$_POST['password']));
- if ( isset( $_POST['submit'] )) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- if ( password_verify($password, $saved_password)) {
- if ($query->rowCount() == 1){
- echo "chrisschotman is ingelogd";
- } else {
- echo "<script type="text/javascript">alert('Wrong username!')</script>";
- }
- } else {
- echo "<script type="text/javascript">alert('Wrong password or username!')</script>";
- }
- }
- ?>
- <form action="" method="post">
- <input type="text" placeholder="username" name="username"maxlength="24"><br>
- <input type="password" placeholder="password" name="password" minlength="8"
- maxlength="16"><br>
- <input type="submit" value="login" name="submit">
- </form>
- <?php
- if (isset($_POST)) {
- include_once('resources/db.php');
- // var_dump($_POST);
- $query = $dbh->prepare('insert into `users`(`username`, `password`) values(?, ?)');
- $username = $_POST['username'];
- $password = $_POST['password'];
- // Create salted password
- $hash_password = password_hash($password, PASSWORD_DEFAULT);
- $query->execute(array($username, $hash_password));
- $query = $dbh->prepare('select * from `users`');
- $query->execute();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement