<?php
ob_start();
//error_reporting(0);
session_start();
require_once('../include/dbconnect.php');
require 'PHPMailer/class.phpmailer.php';
require 'PHPMailer/PHPMailerAutoload.php';

$report = "";

if(isset($_POST['retrieve'])){
  $email_mid = $_POST['email_mid'];

  $get_email = "select * from users where email='".mysqli_real_escape_string($conn, $email_mid)."' or memID='".mysqli_real_escape_string($conn, $email_mid)."'";
  $rungli = $conn->query($get_email);
  $count__ = mysqli_num_rows($rungli);
  
  if($count__ == 1){
		while($rowgli = $rungli->fetch_assoc())
		{
			$li_id= $rowgli['uID'];        
			$li_fn= $rowgli['fn'];         
			$li_ln= $rowgli['ln'];        
			$li_em= $rowgli['email'];        
			$li_mid= $rowgli['memID'];        
			$li_pw= $rowgli['pass'];     
		}
		
		$name = $li_fn."".$li_ln;
		$email = $li_em;
		
		$mail = new PHPMailer;
											
		$mail->isSMTP();
		$mail->SMTPDebug = 0; 
		$mail->Host = "mail.discb3.com";
		$mail->SMTPAuth = true;
		$mail->SMTPSecure = true;
		//$mail->Port = 25; 
		$mail->Port = 465; 
		
		$mail->Username = 'no-reply@discb3.com';
		$mail->Password = 'fe-XB;AYE-$Y';
		
		
		$mail->From = 'no-reply@discb3.com';
		$mail->FromName = 'Citizens Trust - United';
		$mail->addAddress($email,$name);
		
		$mail->IsHTML(true);
		$mail->WordWrap = 50;
			$body="<div style=\"padding:10px;background-color:#f5f5f5;border:1px solid #ccc;min-height:300px;\">";
			$body.="<h3 style=\"border-bottom:1px solid #ccc;padding:10px;\">Dear ".$name.", </h3><p>Kindly find your account login details below:</p>
				<p>
					<strong>Membership ID:</strong> ".$li_mid."<br>
					<strong>Email:</strong> ".$email."<br>
					<strong>Password:</strong> ".$li_pw."
				</p>
				--
				<br>
				<img src='https://www.discb3.com/iportal/images/prime-1.png' style='width: 200px;' alt='Citizens Trust - United'><br>
				
				Email: customercare@discb3.com <br>
				Website: <a href='https://discb3.com/'>www.discb3.com</a> <br>
				Address: 2093 Ryan Road,Sioux Falls South Dakota United States.<hr>
				<p style='text-align: center;'>THIS IS AN AUTOMATED RESPONSE. <b>**DO NOT RESPOND TO THIS EMAIL**</b></p>
			</div>
		";
			
				
				
			
		$mail->Subject = 'Login Details Retrieval';
		$mail->Body    = $body;
		
		
		
		 
			$mail->isHTML(true);
		
		
		if(!$mail->send()){
			echo "<script>alert('Something went wrong! Try again later...')</script>";
			//$error = "<span style='color: indianred; font-size: 15px; font-weight: bold;'>Something went wrong, Try again later...</span>";
		}else{		
      $report =  "<p style='color: limegreen;'>Your request is successful. Check your email for a link to reset your password.</p>";
		}
		$name=$email=NULL;
	}else{
		$report =  "<p style='color: indianred;'>Email or ID does not exist in record!</p>";
	} 
    
}				
?>	
<!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, minimum-scale=1.0, shrink-to-fit=no">
<link href="images/favicon.png" rel="icon" />
<title>User Dashboard - Citizens Trust - United</title>

<meta name="author" content="">

<!-- Web Fonts
============================================= -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap">

<!-- Stylesheet
============================================= -->
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="vendor/font-awesome/css/all.min.css" />
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
<!-- Colors Css -->
<link id="color-switcher" type="text/css" rel="stylesheet" href="#" />



</head>
<body>

<!-- Preloader
<div id="preloader">
  <div data-loader="dual-ring"></div>
</div>
Preloader End -->

<div id="main-wrapper">
  <div class="container-fluid px-0">
    <div class="row g-0 min-vh-100"> 
      <!-- Welcome Text
      ============================================= -->
      <div class="col-md-6">
        <div class="hero-wrap d-flex align-items-center h-100">
          <div style="background:#0000;" class="hero-mask opacity-8 "></div>
          <div class="hero-bg hero-bg-scroll" style="background-image:url('images/bg/image-3.jpg');"></div>
          <div class="hero-content mx-auto w-100 h-100 d-flex flex-column">
            <div class="row g-0">
              <div class="col-10 col-lg-9 mx-auto">
                <div class="logo mt-5 mb-5 mb-md-0"> <a class="d-flex" href="../" title=""><img src="img/DISCOVERY.png" style="width: 200px;" alt=""></a> </div>
              </div>
            </div>
            <div class="row g-0 my-auto">
              <div class="col-10 col-lg-9 mx-auto">
                <h1 class="text-11 text-white mb-4">Welcome back!</h1>
                <p class="text-4 text-white lh-base mb-5">We are glad to see you again! Sign In to access your Online Banking portal.</p>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- Welcome Text End --> 
      
      <!-- Login Form
      ============================================= -->
      <div class="col-md-6 d-flex align-items-center">
        <div class="container my-4">
          <div class="row g-0">
            <div class="col-11 col-lg-9 col-xl-8 mx-auto">
              <h3 class="fw-400 mb-4">Forgot Password</h3>
              <p><?php echo $report; ?></p>
              <form id="loginForm" method="post" action="forgot-password.php">
                <div class="mb-3">
                  <label for="emailAddress" class="form-label">Email Address / Login ID</label>
                  <input type="text" name="email_mid" class="form-control" id="emailAddress" required placeholder="Enter your Email or Login ID">
                </div>
                <div class="d-grid mb-3"><button class="btn btn-primary" name="retrieve" type="submit">Continue</button></div>
              </form>
              <p class="text-3 text-center text-muted">Remember your password? <a class="btn-link" href="login.php">Return to Log In</a></p>
            </div>
          </div>
        </div>
      </div>
      <!-- Login Form End --> 
    </div>
  </div>
</div>

<!-- Back to Top
============================================= --> 
<a id="back-to-top" data-bs-toggle="tooltip" title="Back to Top" href="javascript:void(0)"><i class="fa fa-chevron-up"></i></a> 

<!-- Styles Switcher -->

<!-- Styles Switcher End --> 
<!-- Smartsupp Live Chat script -->
<script src="vendor/jquery/jquery.min.js"></script> 
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script> 
<!-- Smartsupp Live Chat script -->
<!-- Smartsupp Live Chat script -->
<!-- Script --> 
<script src="vendor/jquery/jquery.min.js"></script> 
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script> 
<!-- Style Switcher --> 
<script src="js/switcher.min.js"></script> 
<script src="js/theme.js"></script>
</body>
</html>