Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $msg = "";
- \My PHP code that will execute in before proceeding the change password site
- if(isset($_POST['submitBtnLogin'])) {
- $answer = trim($_POST['ans']);
- $username = ($_SESSION['username']);
- if($answer != "") {
- try {
- $query = "select * from `tbl_user` where username = :username and
- `answer`=:answer";
- $stmt = $db->prepare($query);
- $stmt->bindParam('answer', $answer, PDO::PARAM_STR);
- $stmt->bindParam('username', $username, PDO::PARAM_STR);
- $stmt->execute();
- $count = $stmt->rowCount();
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- if($count == 1 && !empty($row)) {
- $_SESSION['fid'] = $row['id'];
- header('location:changepass.php');
- } else {
- echo "<script>alert('Incorrect Answer');</script>";
- }
- } catch (PDOException $e) {
- echo "Error : ".$e->getMessage();
- }
- } else {
- $msg = "Both fields are required!";
- }
Add Comment
Please, Sign In to add comment