<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert-dev.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css">
  <?php include("head-tag.php");?>
<?php

// include "cn.php";
include "config.inc";
// $connect = Connect();
if (isset($_POST['email_check'])) {
//   	$email = $_POST['customer_email'];
  	$email = $_POST['email'];
  	$sql = "SELECT * FROM app_users WHERE Email='$email'";
  	$results = mysqli_query($connect, $sql);
  	if (mysqli_num_rows($results) > 0) {
  	  echo "taken";
  	}else{
  	  echo 'not_taken';
  	}
  	exit();
 }
else if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $customer_email = $_REQUEST['Email'];

    $query = "SELECT * FROM app_users WHERE Email='" . $customer_email . "'";
    $sql1 = mysqli_query($connect, $query)/* or die("Wrong E-mail Address: ".$connect->error)*/;

    if (!($sql1->num_rows > 0)) {
        // die("Wrong E-mail Address: ".$connect->error);
        // header("Refresh: 0; URL=location:forgot-password.php");
        $message="Oops! EMAIL you entered is not registered";
        echo "<script type='text/javascript'>
        if(!alert('$message')) document.location = 'forgot-password.php';
        </script>";
    } else {
        $customer = mysqli_fetch_assoc($sql1);

        $customer_password = $customer['Password'];
        // email verification goes here

        $to = $customer_email; // Send email to our user
        $subject = $companyname." Forget Password | Recovered"; // Give the email a subject
        $message =
            '
  
Thanks for using Our Service!
Your email and password are as under:.
  
------------------------
Email/Username: ' .
            $customer_email .
            '
Password: ' .
            $customer_password .
            '
------------------------
  
Please click this link to login to your account for booking:
'.$companyweb.'/booking/
  
'; // Our message above including the link

        $headers = "From: ".$companyemailbooking. "\r\n"; // Set from headers
        mail($to, $subject, $message, $headers); // Send our email

        // email verification goes here

        $connect->close();

        $message="Success! Your Password has been sent to your Email";
        echo "<script type='text/javascript'>
        if(!alert('$message')) document.location = 'login.php';
        </script>";
    }
}
?>