JezK
Edit File: verifyMobile.php
<?php include('mainHeader.php'); $page=basename($_SERVER['PHP_SELF']); $userID=$users->encrypt_decrypt('decrypt',$_REQUEST['uid']); $userdet = $users->getusers('id',$userID); ?> <section class="mt-5 pt-4 loginUser-margin"> <div class="container-fluid bg-white text-dark border"> <div class="row p-4"> <div class="col-sm-8 col-md-5 col-lg-4 col-xl-3 side-border"> <img src="img/illustration1.png" width="250px" height="250px"> </div> <div class="col-sm-8 col-md-7 col-lg-8 col-xl-9"> <div class="row "> <div class="col-sm-8 col-md-8 col-lg-6 col-xl-6"> <!-- <form action="" method="POST"> --> <!-- <h6 class="mt-4 mb-5 style-login fancy-underline">Login</h6> --> <h6 class=" mb-5 style-login d-flex">Verify Mobile</h6> <div class="form-group"> <div class="row"> <label for="username" class="fieldName col-6" >We have sent you an otp on</label> <div class="col-6"><a href="changeNumber.php?uid=<?php echo $_REQUEST['uid'];?>" class="text-primary justify-content-end d-flex fs-13">Change Number</a></div> </div> <div class="row"> <div class="col-6"><p class="fs-13">+<?php echo $userdet['0']['country_code'].' '.$userdet['0']['mobile']?></p></div> <!-- <div class="col-6"><a href="" class="text-primary justify-content-end d-flex fs-13">Change Number</a></div> --> </div> <!-- <input type="text" class="form-control formField-control" name="email" id="username"> --> </div> <div class="form-group"> <label for="otp" class="fieldName">OTP</label> <input type="number" class="form-control formField-control" name="otp" id="otp" min="0"> <span class="text-dark fs-13">Still not received OTP?</span> <a href="javascript:void(0);" class="fs-13" style="color:#00C0EC" onclick="resendOtp('<?php echo $_REQUEST['uid'];?>')">Resend Otp</a> </div> <div class="form-group mb-4"> <input type="hidden" name="action" value="otpverification"> <input type="hidden" name="uid" id="uid" value="<?php echo $id;?>"> <input type="hidden" name="mobilenum" id="mobilenum" value="<?php echo $userdet['0']['mobile'];?>"> <button class="btn basic-btn-color w-100" onclick="return verifyotp()">Verify</button> </div> <!-- </form> --> </div> </div> </div> </div> </div> </section> <?php include('mainFooter.php')?> <script type="text/javascript"> function resendOtp(uid){ var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { if(this.responseText == 1){ alert("Successfully sent otp to your mobile number"); return false; }else if(this.responseText==0){ alert("OTP sending failed"); return false; } } }; xmlhttp.open("POST", "ajax.php?mid=" + uid +"&action=resendotp", true); xmlhttp.send(); } function verifyotp() { if($('#otp').val()=='') { alert("Please enter otp");return false; } else{ var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { if(this.responseText == 1){ alert("Successfully verified."); window.location='login.php'; return false; }else if(this.responseText==-1){ alert("OTP mismatched"); return false; } else if(this.responseText==-2){ alert("OTP not existed please resend otp"); return false; } else if(this.responseText==-3){ alert("User Details not existed "); // window.location='login.php'; } else if(this.responseText==-4){ alert("Given otp already verified"); window.location='verifyMobile.php'; } else if(this.responseText==0){ alert("OTP verification failed"); return false; } } }; xmlhttp.open("POST", "ajax.php?mid=<?php echo $_REQUEST['uid'];?>&mobile="+$('#mobilenum').val()+"&action=verifyotp&otp="+$('#otp').val(), true); xmlhttp.send(); } } </script>