<? include("include/system_connect.php");
$action=$_REQUEST['action'];

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no">
    <title>LIXO -  Password Recovery</title>
    <link rel="icon" type="image/x-icon" href="assets/img/favicon.png"/>
    <link href="assets/css/loader.css" rel="stylesheet" type="text/css" />
    <script src="assets/js/loader.js"></script>
    <!-- BEGIN GLOBAL MANDATORY STYLES -->
    <link href="https://fonts.googleapis.com/css?family=Quicksand:400,500,600,700&display=swap" rel="stylesheet">
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/css/plugins.css" rel="stylesheet" type="text/css" />
    <link href="assets/css/structure.css" rel="stylesheet" type="text/css" class="structure" />
    <link href="assets/css/authentication/form-2.css" rel="stylesheet" type="text/css" />
    <!-- END GLOBAL MANDATORY STYLES -->
    <link rel="stylesheet" type="text/css" href="assets/css/forms/theme-checkbox-radio.css">
    <link rel="stylesheet" type="text/css" href="assets/css/forms/switches.css">
	<script language="javascript" type="text/javascript">
function logincheck()
{ 
			if(document.formlogin.member_id.value=="")
			{				
				alert("Enter Member ID");
				document.formlogin.member_id.focus()
				return false;
			}			
			
			  
			
			
			return true;    
}
</script>
</head>
<body class="form no-image-content">
    

    <div class="form-container outer">
        <div class="form-form">
            <div class="form-form-wrap">
                <div class="form-container">
                    <div class="form-content">

                        <h1 class="">Password Recovery</h1>
                        <p class="signup-link recovery"><? if($_SESSION['msg']!="")
				{?>
			<? echo $_SESSION['msg'];?>
			<? } unset($_SESSION['msg']);?></p>
                        <form class="text-left" action="forgot_pass.php?action=process" onSubmit="return logincheck();" name="formlogin" method="post">
                            <div class="form">

                                <div id="email-field" class="field-wrapper input">
                                    <div class="d-flex justify-content-between">
                                        <label for="email">Member ID</label>
                                    </div>
                                    
                                    <input class="form-control" placeholder="Member ID" name="member_id" type="text">
                                </div>
<p class="signup-link recovery"><a href="index.php"> Send me back</a> to the sign in screen.</p>
                                <div class="d-sm-flex justify-content-between">

                                    <div class="field-wrapper">
                                        <button type="submit" class="btn btn-primary" value="">Reset</button>
                                    </div>
                                </div>

                            </div>
                        </form>

                    </div>                    
                </div>
            </div>
        </div>
    </div>

    
    <!-- BEGIN GLOBAL MANDATORY SCRIPTS -->
    <script src="assets/js/libs/jquery-3.1.1.min.js"></script>
    <script src="bootstrap/js/popper.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>
    
    <!-- END GLOBAL MANDATORY SCRIPTS -->
    <script src="assets/js/authentication/form-2.js"></script>

</body>
</html>
<?
if($action=="process")
{









 $member_id=$_REQUEST['member_id'];







if($mob==""){$mob="NULL";}









			  $query = $mysqli->prepare('SELECT * FROM member where member_id=?');





								$query->bind_param("s", $member_id);





						$query->execute();



						$query->store_result();



						$no=$query->num_rows;



			  if($no==0)



			  {







			  $_SESSION['msg']="Member ID Not Found.Try Again.";







header("location:forgot_pass.php");





			  }



			  else





			  {




				  

				   





		$qury=$mysqli->prepare("select name,password,t_password,login_otp,mob  from member where member_id=?");



								 $qury->bind_param("s", $member_id);



								 $qury->execute();



								  $qury->bind_result($name,$password,$t_password,$login_otp,$mob);



								  while($qury->fetch())





									{



									$name=$name;
									$login_otp=$login_otp;



									$password=$password;

									$t_password=$t_password;
									
									$mob=$mob;



									}	

				  

				  
$query2=$mysqli->prepare("select email from user where member_id=?");
$query2->bind_param("s", $member_id);
 $query2->execute();
$query2->bind_result($db_email);
 while($query2->fetch())
{
$db_email=$db_email;
}


	
$name=$name;

$member_id=$_REQUEST['member_id'];

  



 $name=$name;



  
$to = $db_email;


$subject = 'PASSWORD RECOVERY';
$from = 'support@lixo.io';
 
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
// Create email headers
$headers .= 'From: '.$from."\r\n".
    'Reply-To: '.$from."\r\n" .
    'X-Mailer: PHP/' . phpversion();

 

$message = 'Hi <br>';
$message .=$name;
$message .='YOUR PASSWORD IS : ';
$message .=$password;
$message .= '<br><br>';
$message .='AND T-PASSWORD IS : ';
$message .=$login_otp;
$message .= '<br><br>';
$message .='Please do not reply to this email. Emails sent to this address will not be answered.';

 
// Sending email
if(mail($to, $subject, $message, $headers)){
    echo 'Your mail has been sent successfully.';
} else{
    echo 'Unable to send email. Please try again.';
}






 $_SESSION['msg']="Password Has been sent To your Email ID.";	











header("location:forgot_pass.php");


















}







}
?>