<?php
 ini_set('session.gc_maxlifetime', 30*60);

session_start();




include '../includes/config.php';

	$Error ='';
	
	
	
$DID = $_GET['DID'];
$user_ID = $_GET['user_ID'];




 
  


if(isset($_POST['Submit']))
{
	
	
$Phone_Number = mysqli_real_escape_string($dbConn,$_POST['Phone_Number']);



$DID=mysqli_real_escape_string($dbConn,$_POST['DID']);
$user_ID=mysqli_real_escape_string($dbConn,$_POST['user_ID']);





$sql = mysqli_query($dbConn,"select * from drivers where Phone_Number='$Phone_Number'");

if (mysqli_num_rows($sql)>0){

$row = mysqli_fetch_array($sql);
$D_ID = $row['ID'];

$Password = substr(sha1(mt_rand()),17,7);

$sql1 = mysqli_query($dbConn,"update drivers set Password='$Password' where ID='$D_ID'");





	$Error = 'Your new password has been sent to your phone number !';

	
	
}else{
	
	



	$Error = 'Error - please check phone number !';

	
	


}
























}

?>

<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <!-- FontAwesome -->
    <link rel="stylesheet" href="../css/fontawesome.css">
    <!-- Main Style -->
    <link rel="stylesheet" href="../css/styles.css">
	
	<link rel="shortcut icon" href="../images/icon.ico"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,user-scalable=0"/>



    <title>Forget password</title>
	
	
	
	
	<style>
@font-face {
   font-family: myFirstFont;
   src: url(../fonts/Arial-Rounded-MT-Bold-Regular.ttf);
   font-size:8px;
}



body {
   font-family: myFirstFont !important;
   text-align: right !important;
}


</style>
	








</head>
<body >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

<!--Loading Container Start-->
<div id="load" class="loading-overlay display-flex flex-column justify-content-center align-items-center">
    <div class="primary-color font-28 fas fa-spinner fa-spin"></div>
</div>
<!--Loading Container End-->

<div class="row h-100">
    <div class="col-xs-12 col-sm-12">

        <!--Page Title & Icons Start-->
        <div class="header-icons-container text-center">
          <a href="Drivers-Sign-In.php?DID=<?php echo $DID; ?>&user_ID=<?php echo $user_ID; ?>">
                <span class="float-left">
                    <img src="../icons/back.svg" alt="Back Icon">
                </span>
            </a>
            <span><br>Forget password</span>
        </div>
        <!--Page Title & Icons End-->

        <div class="rest-container">
            <div class="text-center header-icon-logo-margin header-icon-logo-margin-extra">
                <img src="../images/logo.png" width="75%" style="border-radius: 10%;" alt="Main Logo">
            </div>

            <!--Sign Up Container Start-->
            <div class="sign-up-form-container text-center">
                <form class="width-100" method="post" action="Drivers-Forget-Password.php?DID=<?php echo $DID; ?>&user_ID=<?php echo $user_ID; ?>">
				
	   <INPUT TYPE="hidden" NAME="DID"  VALUE="<?php echo $DID; ?>">
	 	   <INPUT TYPE="hidden" NAME="user_ID"  VALUE="<?php echo $user_ID; ?>">
		   
		   
				
 





	 

                   <!--Sign Up Form Field Start-->
                   <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span>
                                    <img src="../icons/phone.svg" alt="Lock Icon">
                                </span>
                            </div>
                            <input class="form-control" type="tel"  name="Phone_Number" placeholder="Phone number" required>
                            <div class="input-group-append password-visibility">
                               
                            </div>
                        </div>
                    </div>
                    <!--Sign Up Form Field End-->

                

                    <div class="form-submit-button">
                        <input type="submit" name="Submit" style="height:50px; font-size: 16px; border-style: dashed; width:311px !important; border-radius: 50px; color:#011F39; border-color:#B3E207; background-color:#ebebeb" class="btn  w-100 mb-3" value="Reset password"/>
						
						<br><br>
											<center><span style="color:red"><?php echo $Error; ?></span></center>

                    </div>
                </form>
				
					

				
				
				
				
            </div>
            <!--Sign Up Container Start-->

        </div>
    </div>

    

</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->







<script src="../js/jquery-3.4.1.js"></script>
<script src="../js/popper.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/main.js"></script>



<p id="demo"></p>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
 



</body>
</html>