JezK
Edit File: verifyMobile.php
<?php include('mainHeader.php'); // $page=basename($_SERVER['PHP_SELF']); $bid=$videocon->encrypt_decrypt('decrypt',$_REQUEST['bid']); // echo $bid ;exit; $businessData=$videocon->getBusiness('id',$bid); ?> <section class="mt-5 pt-4 loginUser-margin"> <div class="container-fluid bg-white text-dark border"> <div class="row p-4 justify-content-center align-items-center"> <div class="col col-sm-8 col-md-8 col-lg-6 col-xl-5"> <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?bid=<?php echo $_REQUEST['bid'];?>" 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 $businessData['0']['country_code'].' '.$businessData['0']['mobile']?></p></div> </div> </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" onclick="resendOtp('<?php echo $_REQUEST['bid'];?>')">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 $businessData['0']['mobile'];?>"> <button class="btn basic-btn-color w-100" onclick="return verifyotp()">Verify</button> </div> </div> </div> </div> </section> <?php include('mainFooter.php')?> <script type="text/javascript"> function resendOtp(bid){ 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=" + bid +"&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='signupSuccess.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['bid'];?>&mobile="+$('#mobilenum').val()+"&action=verifyotp&otp="+$('#otp').val(), true); xmlhttp.send(); } } </script>