prepare("SELECT * FROM users WHERE username = :username"); $stmt->bindParam(":username", $username); $stmt->execute(); // set the resulting array to associative $result = $stmt->fetchAll(PDO::FETCH_ASSOC); if ($result) { if (password_verify($password, $result[0]["password"])) { return true; } return false; } return false; } function createToken(): string { return uniqid("rpe-"); } function checkEmail($email): bool { $conn = dbConn(); $stmt = $conn->prepare("SELECT * FROM users WHERE email = :email"); $stmt->bindParam(":email", $email); $stmt->execute(); // set the resulting array to associative $result = $stmt->fetchAll(PDO::FETCH_ASSOC); if ($result) { return true; } return false; } function sendResetEmail($email): string { //generate a random token and email the address $token = $this->createToken(); $headers1 = "From: noreply@rohitpai.co.uk\r\n"; $headers1 .= "MIME-Version: 1.0\r\n"; $headers1 .= "Content-Type: text/html; charset=UTF-8\r\n"; $message = " Document

Reset Password Verification Code


Please enter the following code to reset your password: $token

"; mail($email, "Reset Password Verification Code", $message, $headers1); return $token; } }