JezK
Edit File: index.php
<?php // ini_set('display_errors', 1); // ini_set('display_startup_errors', 1); // error_reporting(E_ALL); include("mainHeader.php") ; $page=basename($_SERVER['PHP_SELF']); if(isset($_POST['action']) && $_POST['action'] =='login') { $login=$videocon->login($_POST); if($login == -1){ echo "<script>alert('Your account has been deleted by admin. Please contact administrator.');</script>"; } else if($login == -2){ echo "<script>alert('Your account has been blocked by admin. Please contact administrator.');</script>"; } else if($login == -9){ echo "<script>alert('Only accessble by ".$recentPractCountry." country professional please contact admin.');</script>"; } else if($login == 1){ echo "<script>window.location='dashboard.php';</script>";exit; }else if($login == 0){ echo "<script>alert('Invalid Credentials');</script>"; } else { // $userID = $users->getUsers('username',$_POST['username']); $businessDet=$videocon->getBusiness('username',$_POST['username']); $otpsent=$videocon->sendOtp($businessDet['0']['mobile'],$businessDet['0']['country_code'],$businessDet['0']['id']); $id=$videocon->encrypt_decrypt('encrypt',$businessDet['0']['id']); echo "<script>alert('please verify your mobile');window.location='otp.php?mid=".$id."'</script>"; } } if(isset($_POST['action']) && $_POST['action']=='forgotPassword') { $forgotpswd = $videocon->forgetPassword($_POST); if($forgotpswd == 1) { echo "<script>alert('Password sent to registered mail/mobile');window.location='index.php';</script>";exit; }else if($forgotpswd == -1){ echo "<script>alert('Internal server error please try again')</script>"; } else{ echo "<script>alert('Given details does not exist ')</script>"; } } /* if(isset($_POST['action']) && $_POST['action']=='checkMobile') { $checkMobile = $videocon->checkMobileNumber($_POST); if($checkMobile == 1) { $encrypt=$videocon->encrypt_decrypt('encrypt',$_POST['mobile']); echo "<script>window.location='otp.php?mob=".$encrypt."';</script>";exit; } else{ echo "<script>alert('Invalid mobile number');window.location='index.php';</script>";exit; } } */ ?> <section class="mt-5 pt-4"> <div class="container-fluid bg-light text-dark"> <div class="row justify-content-center align-items-center login-border"> <div class="col col-sm-8 col-md-8 col-lg-6 col-xl-5"> <form action="" method="POST"> <ul class="nav nav-tabs border-0 pb-4"> <li class="nav-item list-tabs"> <a class="nav-link anc-Colorcurrent list-tabs-link <?php if($page == 'index.php'){echo 'active'; }else { echo ''; } ?>" href="index.php">Login</a> </li> <li class="nav-item"> <a class="nav-link anc-Colorcurrent list-tabs-link <?php if($page == 'createBusinessAccount.php'){echo 'active'; }else { echo ''; } ?> " href="createBusinessAccount.php">Create Business Account</a> </li> </ul> <!-- <h6 class="mt-4 mb-5 style-login fancy-underline">Login</h6> --> <div class="form-group"> <label for="username" class="fieldName">Username</label> <input type="text" class="form-control formField-control" name="username" id="username" value="<?php if(isset($_POST['username']) && $_POST['username']!=''){ echo $_POST['username']; }?>"> </div> <div class="form-group"> <label for="password" class="fieldName">Password</label> <input type="password" class="form-control formField-control" name="password" id="password" value="<?php if(isset($_POST['password']) && $_POST['password']!=''){ echo $_POST['password']; }?>"> </div> <div class="d-flex justify-content-between align-items-center"> <div class="custom-control custom-checkbox custom-checkbox-customize"> <!--<input type="checkbox" id="rememberMe" class="custom-control-input"> <label for="rememberMe" class="custom-control-label remember">Remember me</label>--> </div> <a href="" data-toggle="modal" data-target="#myModal" class="float-right fieldName-forgot">Forgot Password?</a> </div> <input type="hidden" name="action" value="login"> <div class="custom-control custom-checkbox custom-checkbox-customize"> <input type="checkbox" id="loginWithOtp" name="otpLogin"class="custom-control-input" value ="value2"> <label for="loginWithOtp" class="custom-control-label remember" data-toggle="modal" data-target="#otpModel">Login with OTP instead password</label> </div> <div class="form-group mt-4 mb-2"> <button class="btn basic-btn-color w-100" >Login</button> </div> <div class="text-center mb-4"> <a href="createBusinessAccount.php" class="btn btn-secondary w-100 text-white fieldName-forgot border-0 fieldName-forgot">Create Your Business Signup</a> </div> <div class="form-group"> <p style="text-align: center; font-size: small;">version: 2.2</p> </div> <!-- <div class="form-group"> <p class="text-center m-0">...............or...............</p> </div> --> <!-- <div class="form-group mb-5"> <button class="btn bg-ocean-blue text-white w-100"><img class="img pr-3" src="img/f.png" />Connect with facebook</button> </div> --> </form> </div> </div> </div> </section> <div class="container"> <!-- The Modal --> <div class="modal" id="myModal"> <div class="modal-dialog"> <div class="modal-content"> <!-- Modal Header --> <div class="modal-header border-0"> <button type="button" class="close px-2 pt-2 pb-0" data-dismiss="modal">×</button> </div> <!-- Modal body --> <div class="modal-body mx-4"> <h5 class="modal-title style-login mb-3">Forgot Password</h5> <p class="modal-font"> Enter your registerd email. We will send you mail to recover your password</p> <!--start password Form --> <form action="" method="POST"> <div class="form-group"> <label for="forget_email" class="fieldName">Email ID/Mobile Number</label> <input type="text" class="form-control formField-control" name="email" id="forgetemail"> </div> <div class="form-group"> <input type="hidden" name="action" value="forgotPassword"> <button class="btn basic-btn-color w-100" onclick="return forgetEmail();" >Submit</button> </div> </form> <!--end password Form --> </div> </div> </div> </div> </div> <div class="container"> <!-- The Modal --> <div class="modal" id="otpModel" data-backdrop="static" data-keyboard="false"> <div class="modal-dialog"> <div class="modal-content"> <!-- Modal Header --> <div class="modal-header border-0"> <button type="button" class="close px-2 pt-2 pb-0" data-dismiss="modal">×</button> </div> <!-- Modal body --> <div class="modal-body mx-4"> <h5 class="modal-title style-login mb-3">Login with OTP</h5> <p class="modal-font"> Enter your registerd mobile number. We will send otp for Login</p> <!--start password Form --> <form method="POST" > <div class="form-group"> <label for="username" class="fieldName">Mobile</label> <input type="text" class="form-control formField-control " name="mobile" id="mobile" maxlength="15" minlength="5" required> </div> <div class="form-group"> <input type="hidden" name="action" value="checkMobile"> <button type="button" onclick="return checkMobile()" class="btn basic-btn-color w-100">Submit</button> </div> </form> <!--end password Form --> </div> </div> </div> </div> </div> <script> function loginvalidation() { if($('#username').val()=='') { alert('Please enter username'); return false; } else if($('#password').val()==''){ alert('Please enter password'); return false; } } </script> <?php include("mainFooter.php") ?> <script> function forgetEmail() { var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; if ($('#forgetemail').val() == '') { alert('Please enter email/mobile'); return false; } else if (isNaN($('#forgetemail').val())) { var email = $('#forgetemail').val(); var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; if (reg.test(email) == false) { alert("Please enter valid email address"); return false; } } else { var phoneno = /^\d{5,15}$/; if (!$('#forgetemail').val().match(phoneno)) { alert("Please enter valid Mobile Number"); return false; } } } function checkMobile() { if($('#mobile').val()=='') { alert('Please enter mobile number');return false; } else{ var phoneno = /^\d{5,15}$/; if(!$('#mobile').val().match(phoneno)) { alert("Please enter valid Mobile Number");return false; } else{ var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { if(this.responseText == -7){ alert('Your account has been deleted by admin. Please contact administrator.');return false; } else if(this.responseText == -2){ alert('Your account has been blocked by admin. Please contact administrator.');return false; } else if(this.responseText == -9){ alert('Only accessble by <?php echo $recentPractCountry;?> country professional please contact admin.');return false; } else { if(this.responseText==0) { alert("OTP sending failed");return false; } else if(this.responseText==-1) { alert('Given mobile number not exist');return false; } else { alert('Successfully sent otp to given mobile number'); window.location='otp.php?mid='+this.responseText; } } return false; } }; xmlhttp.open("POST", "ajax.php?action=sendotp&mobile="+ $('#mobile').val(), true); xmlhttp.send(); return false } return false } return false } $("#otpModel .close").click(function(){ $("#loginWithOtp").prop("checked", false); }) </script>