JezK
Edit File: resetpassword.php
<?php include "head.php"; ?> <?php $encoded_id = $_GET['id']; $token = $_GET['token']; $id = base64_decode($encoded_id); ?> <section class="login-section"> <div class="container-fluid"> <div class="row no-gutters"> <div class="col-md-6 d-none d-md-block p-0"> <img src="./images/forget-password.png" class="img-fluid" style="min-height:90%;" /> </div> <div class="col-md-6 form-container"> <div class="logo-container"> <img src="./images/logo.png" class="img-fluid logo_img" /> </div> <h3 class="login-heading">Set New Password</h3> <div class="form-style mt-4"> <form id="setNewPswdForm"> <div class="form-group pb-2 position-relative"> <label for="npassword" class="form-label">New Password</label> <input type="password" placeholder="New Password" class="form-control" name="password" id="npassword"> <span class="toggle-icon"><i class="fa fa-eye"></i></span> <div class="error npassworderror"></div> <p class="error password_error"></p> </div> <div class="form-group pb-2 position-relative"> <label for="cpassword" class="form-label">Confirm Password</label> <input type="password" placeholder="Confirm Password" class="form-control" id="cpassword"> <span class="toggle-icon"><i class="fa fa-eye"></i></span> <div class="error cpassworderror"></div> <p class="error password_error"></p> </div> <div class="error passworderror"></div> <input type="hidden" id="id_" value="<?php echo $id; ?>" /> <input type="hidden" id="token" value="<?php echo $token; ?>" /> <div class="mt-1 d-flex justify-content-center"> <button type="submit" class="de-btn-fill" onclick="return validatePassword()">Submit</button> </div> </form> </div> </div> </div> </div> </section> <?php include "scripts.php"; include "../App/userObject.php"; ?> <script> let baseUrl = "<?php echo $baseUrl ?>"; $(document).ready(function() { $('.toggle-icon').click(function() { var input = $(this).closest('.form-group').find('input'); 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'); } }); }); </script> <script> $('#setNewPswdForm').submit(function(event) { event.preventDefault(); let newpassword = $('#npassword').val(); let confirmpassword = $('#cpassword').val(); let id = $('#id_').val(); let token = $('#token').val(); $.ajax({ url: baseUrl + 'admin/app/subresetPassword.php', method: 'POST', data: { name: 'cpw', newpassword: newpassword, confirmpassword: confirmpassword, id: id, token: token }, success: function(response) { if (response == 1) { toastr.success('Password updated! Log in with your new password.') function redirectLogin() { location.replace(baseUrl + 'sub-admin/index.php'); } setTimeout(redirectLogin, 2000); } else if (response == 2) { toastr.warning('Invalid Link') } else { toastr.warning('Unable to Change') } }, error: function() { $('.passworderror').html('An error occurred. Please try again.').show(); } }); }); </script>