Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require 'conn.php';
- if (isset($_POST['login'])) {
- $uname = $_POST['username'];
- $pwd = $_POST['password'];
- $sql = "SELECT * FROM chat WHERE username = ?";
- $stmt = $db->prepare($sql);
- // you just need to find matching username
- $stmt->bind_param("s", $uname);
- $stmt->execute();
- $result = $stmt->get_result();
- $re = $result->fetch_assoc()
- // check if matching username is found, then verify hashed password from database
- if ($re && password_verify($pwd, $re['password'])) {
- $_SESION['username'] = $re['username'];
- exit(header('location: home.php'));
- } else {
- echo "wrong username/password";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement