JezK
Edit File: otp.php
<?php include('mainHeader.php'); $page=basename($_SERVER['PHP_SELF']); $id=$videocon->encrypt_decrypt('decrypt',$_REQUEST['mid']); $businessDet = $videocon->getBusinessDetails($id); // print_r($businessDet);exit; /* if(isset($_POST['action']) && $_POST['action']=='otpverification'){ $getotp=$videocon->getbusinessOtp($businessDet['id'],$businessDet['mobile']); $errors=''; if($_POST['otp']==''){ $errors.="Please enter 6 digit otp\\n"; } else if(@count($getotp)<=0) { $errors.="OTP not exist\\n"; }elseif($getotp['otp']!=$_POST['otp']){ $errors.="OTP is mismatched\\n"; } if($errors==''){ $votp=$videocon->verifyotp($getotp['id']); if($votp>0){ echo "<script language='javascript'>alert('OTP verified Successfully');window.location='dashboard.php'</script>"; }else{ echo "<script language='javascript'>alert('OTP verification is failed');</script>"; } }else{ echo "<script language='javascript'>alert('".$errors."');</script>"; } } */ ?> <section class="mt-5 pt-4 mx-5 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"> <!-- <form action="" method="POST"> --> <h6 class="mt-4 mb-5 style-login justify-content-center d-flex">Login with OTP</h6> <div class="form-group"> <div class="row"> <label for="username" class="fieldName col-6" >We have sent you an otp on</label> </div> <div class="row"> <div class="col-6"> <p class="fs-13">+<?php echo $businessDet['country_code'].' '.$businessDet['mobile']?></p></div> </div> </div> <div class="form-group"> <label for="otp" class="fieldName">OTP</label> <input type="text" class="form-control formField-control" name="otp" id="otp"> <span class="text-dark fs-13">Still not received OTP</span> <!-- <a href="javascript:void(0);" class="fs-13" onclick="resendOtp('<?php echo $businessDet['id'];?>','<?php echo $businessDet['mobile'];?>')">Resend Otp</a> --> <input type="hidden" name="mobilenum" id="mobilenum" value="<?php echo $businessDet['mobile'];?>"> <a href="javascript:void(0);" class="fs-13" onclick="resendOtp('<?php echo $_REQUEST['mid'];?>')" >Resend Otp</a> </div> <div class="form-group mb-4"> <input type="hidden" name="action" value="otpverification"> <button class="btn basic-btn-color w-100" onclick ="return verifyotp()">Login</button> </div> <!-- </form> --> </div> </div> </div> </div> </section> <?php include('mainFooter.php')?> <script type="text/javascript"> function resendOtp(mid){ 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==2){ alert("OTP sending failed"); return false; } } }; xmlhttp.open("POST", "ajax.php?mid=" + mid +"&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) { // alert(this.responseText) ; if(this.responseText == 1){ // alert("Successfully verified"); window.location='dashboard.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='index.php'; } else if(this.responseText==0){ alert("OTP verification failed"); return false; } } }; xmlhttp.open("POST", "ajax.php?mid=<?php echo $_REQUEST['mid'];?>&mobile="+$('#mobilenum').val()+"&action=verifyotp&otp="+$('#otp').val(), true); xmlhttp.send(); } } </script>