<?php include("config.inc");

$isError=false;

$usrname=$_REQUEST["username"];
$password=$_REQUEST["password"];

    $qry=mysqli_query($connect, "SELECT * FROM app_users WHERE email='".$_REQUEST["username"]."' AND Password='".$_REQUEST["password"]."' AND emailverified='1' ") or die("Error " .mysqli_error());
    $data1=mysqli_fetch_assoc($qry);
    
        
    if(mysqli_num_rows($qry)>0){
        $_SESSION['userid']=$data1['Id'];
        $_SESSION['name']=$data1['Name'];
        $_SESSION['email']=$data1["Email"];
        $_SESSION['password']=$data1['Password'];
        $_SESSION['image']=$data1["Image"];
        $_SESSION['driverid']=$data1['DriverId'];
		
		$_SESSION['customerlogged'] = true;
		
		if (isset($_POST['id'])) {
                $_SESSION['carid'] = $_POST['id'];
                header("location: booknow.php"); //redirect to booking page
            } else {
                // header("location: index.php#cars"); // Redirecting To Index Page for Car Selection
                header("location:index.php");
            }
        } else {
        $isError=true;
		$error_msg = "Your username or password is invalid";
        }
 ?>