JezK
Edit File: resendotp.php
<?php $encodedToken = $_GET['token']; $token = base64_decode($encodedToken); $verifyStatus = $_GET['verifyStatus']; ?> <!doctype html> <html lang="en"> <head> <title>Detailing Edition - Login</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="icon" type="image/png" href="./images/fav.png"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@200;400;800&family=Mulish:wght@300;400;700&display=swap" rel="stylesheet"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.7/css/all.css"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <link rel="stylesheet" href="./userstyles/userstyles.css"> <script src="js/validations.js"></script> </head> <body class="login-section"> <section> <div class="container-fluid"> <div class="row no-gutters"> <div class="col-md-6 d-none side-image p-0"> <img src="./images/logo.png" class="img-fluid" /> </div> <div class="col-md-5 form-container"> <div class="otp-contents"> <h3 class="login-heading">OTP Verification</h3> <div class="form-style"> <!-- <form id="otpForm"> <div class="form-group pb-2"> <p class="align-center" style="color:white; font-size:16px;">Please enter the verification code sent to your mobile number</p> <label for="phone" class="form-label">OTP</label> <input type="phone" class="form-control" id="otp1" name="otp1"> <div class="text-center"> <button type="button" class="no-btn text-white" onclick="resnedOtp()">Resend OTP</button> </div> <p class="error otp_error"></p> </div> <div class="error loginerror"></div> <div class="my-2 d-flex justify-content-center"> <button type="submit" class="de-btn-fill" onclick="return validateOtp();" name="login">Submit</button> </div> </form> --> <form id="otpForm"> <div class="form-group pb-2"> <p class="text-center text-white">Please enter the verification code sent to your mobile number</p> <div class="d-flex justify-content-center"> <input type="text" class="form-control otp-digit" id="otp1" name="otp1" maxlength="1" oninput="focusNext(this)"> <input type="text" class="form-control otp-digit" id="otp2" name="otp2" maxlength="1" oninput="focusNext(this)"> <input type="text" class="form-control otp-digit" id="otp3" name="otp3" maxlength="1" oninput="focusNext(this)"> <input type="text" class="form-control otp-digit" id="otp4" name="otp4" maxlength="1" oninput="focusNext(this)"> </div> <div class=" "> <button type="button" class="no-btn text-white" onclick="resendOtp()">0:30</button> </div> <p class="error otp_error"></p> </div> <div class="error loginerror"></div> <div class="my-2 d-flex justify-content-center"> <button type="submit" class="de-btn-fill" onclick="return validateOtp();" name="login">Submit</button> </div> </form> </div> <div class="login"> <br> <h5><a href="index.php">Login</a></h5> </div> </div> </div> <div class="col-md-1 p-0"> </div> </div> </div> </section> <?php include "./scripts.php"; include "./App/userObject.php"; ?> <script> let baseUrl = "<?php echo $baseUrl; ?>"; let token = "<?php echo $token ?>"; $(document).ready(function() { $('.toggle-icon').click(function() { var input = $('#password'); if (input.attr('type') === 'password') { input.attr('type', 'text'); $(this).find('i').removeClass('fa-eye').addClass('fa-eye-slash'); } else { input.attr('type', 'password'); $(this).find('i').removeClass('fa-eye-slash').addClass('fa-eye'); } }); $('#otpForm').submit(function(event) { event.preventDefault(); let otpNumber1 = $('#otp1').val(); let verifyStatus = "<?php echo $verifyStatus; ?>"; let otpNumber = otpNumber1; $.ajax({ url: 'App/forgotpassword.php', method: 'POST', data: { otp: 'otp', otpNumber: otpNumber, token: token, verifyStatus }, success: function(response) { data = JSON.parse(response); let token = data.token; if (data.status == 1) { if (verifyStatus == 2) { location.replace('resetpassword.php?token=' + token); } else { location.replace('index.php'); } } else { toastr.warning("Wrong Otp"); } } }); }); }); function resnedOtp() { $.ajax({ url: 'App/forgotpassword.php', method: 'POST', data: { resend: 'resend', token: token, }, success: function(response) { if (response == 1) { toastr.success("Otp Send"); } else { toastr.warning("Unable to send otp"); } } }); } </script> </body> </html>