<?php 
require_once('includes/config.php'); 
require_once('sms.php'); 
$error="";
if(isset($_POST['submit'])){
    $mobile=$_POST['mobile_number']; 
    $reset_qry= $con->query("SELECT user_id FROM user_details WHERE `phone` = '".$mobile."'");
    if(mysqli_num_rows($reset_qry)>0){
    $result=mysqli_fetch_array($reset_qry);    
    $time     = time();              
    $encrypt  = md5(90*13+$result['user_id']); 
    $otp=rand(1111,9999);
    $message="<#> $otp is OTP for Workapp";
    sendsms($mobile,urlencode($message));
    $reset_qry= $con->query("UPDATE users SET otp='$otp',otp_verified='0' WHERE  `user_id` = '".$result['user_id']."'");
    header('Location:'.$base_url.'reset-password.php?encrypt='.$encrypt.'&tamp='.$time.'');
    }else{
        $error="Mobile number not matching";
    }
}
require_once('includes/pre-header.php'); 
?>
<body class="hold-transition login-page">
<div class="login-box">
  <div class="login-logo">
    <a href="index.php">
      <b>WORK</b>
      <small>Together</small>
    </a>
  </div>
  <!-- /.login-logo -->
  <div class="login-box-body">
   <p class="login-box-msg" style="color:red;"><?php echo $error;?></p>
    <div class="col-lg-12 message"></div>
    <form id="loginForm" method="POST">
      <div class="form-group has-feedback">
        <input type="number" class="form-control" id="mobile_number" name="mobile_number" placeholder="Mobile Number" required/>
        <span class="glyphicon glyphicon-phone form-control-feedback"></span>
      </div>
      <div class="row">
         <div class="col-xs-8">
          <div class="checkbox icheck">
            <label>
              <a href="index.php">Back to login</a>
            </label>
          </div>
        </div>
        <!-- /.col -->
        <div class="col-xs-4">
          <input type="submit" name="submit" class="btn btn-primary btn-block btn-flat" id="sign_in" value="Submit" />
        </div>
        <!-- /.col -->
      </div>
    </form>    
  </div>
  <!-- /.login-box-body -->
</div>
<!-- /.login-box -->
<!-- jQuery 3 -->
<script src="jquery/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="bootstrap/dist/js/bootstrap.min.js"></script>
<!-- For data alerts -->
<script src="dist/js/simply-toast.min.js"></script>
<script src="js/common.js"></script>
</body>
</html>
