Hello there I am trying to update the password but whenever I execute this code it gives an error message. Is anyone here can check this code tell me how to fix this.. What I did i created php code for forgot password using token and email and successfully can run the code. But whenever I run this code below it doesn't execute the code. I am new in programming so can anyone here help me this code. PHP: <?php if (isset($_GET["token"]) && isset($_GET["email"])) { include("config.php"); $password = $con->real_escape_string($_POST['password']); $cPassword = $con->real_escape_string($_POST['cPassword']); $data = $con->query("SELECT id FROM users WHERE email='$email' AND token='$token'"); if ($data->num_rows > 0) { $password = $con->real_escape_string($_POST['password']); $cPassword = $con->real_escape_string($_POST['cPassword']); if ($password != $cPassword) $msg = "Please check your password again!"; else{ $hashedPassword = password_hash($password, PASSWORD_BCRYPT); $con->query("UPDATE users SET password = '$hashedPassword', token = '' WHERE email='$email'"); echo "Your new password is: $password"; } else { echo "Please check your link!"; } } } else { header("Location: login.php"); exit(); } ?> And the HTML is as follows HTML: <html> <body> <form class="login100-form validate-form" method="post" action="resetPassword.php"> <span class="login100-form-logo"> <img src="images/logo.png" alt="logo"></img> </span> <span class="login100-msg"><br> <?php if ($msg != "") echo $msg . "<br>" ?></span> <span class="login100-form-title p-b-34 p-t-27"> Update Your Password </span> <div class="wrap-input100 validate-input" data-validate = "Enter password"> <input class="input100" type="password" name="password" placeholder="Enter Password"> <span class="focus-input100" data-placeholder=""></span> </div> <div class="wrap-input100 validate-input" data-validate = "Enter cPassword"> <input class="input100" type="text" name="cPassword" placeholder="Enter Password Again"> <span class="focus-input100" data-placeholder=""></span> </div> <div class="container-login100-form-btn"> <button class="login100-form-btn" type="submit" name="forgotPass"> Update Password </button> </div> </form> </body> </html>
For that you have to assign the variable like Code: $token = $_GET["token"]; or rather Code: $token = $con->real_escape_string($_GET['token']);