<?php
	session_start();


    require('connect.php');
    require('functions.php');


    $log=loggedin();
    if($log===true)
    {
        if($_SESSION['type']==="1")
          header('Refresh:0 url=main.php');
        else if($_SESSION['type']==="2")
          header('Refresh:0 url=driver.php');
        else if($_SESSION['type']==="3")
          header('Refresh:0 url=admin.php');

    }


	//echo '<script>alert("BEFORE BUTTEN PRESS");</script>';

	//echo "hiii krushna ";

	if(isset($_POST['customer_login_btn']))
	{
		//echo '<script>alert("AFTER BUTTEN PRESS");</script>';
		if($_POST['cuser']=="" || $_POST['cpassword']=="")
		{
			echo '<script>alert("All fields must be filled out");</script>';
		}
		else
		{
			$username=$_POST['cuser'];
			$username=test_input($username);
			$password=$_POST['cpassword'];
			$password=test_input($password);

			$r="SELECT * FROM customer WHERE cemail='".$username."' and cpassword='".$password."'";

			$r=mysqli_query($con,$r);

			if(mysqli_num_rows($r) > 0)
			{

				$_SESSION['id']=$username;
				$_SESSION['type']="1";
                        $row = mysqli_fetch_array($r);
                        $_SESSION["CID"]=$row['CID'];
				echo '<script>alert("wellcome to abhi cab");</script>';
				header('Refresh:0 url=main.php');
			}
			else
			{
				echo "<script type='text/javascript'>alert('password or email id is not correct..!!!');</script>";
			}

		}
	}

	if(isset($_POST['driver_login_btn']))
	{
		//echo '<script>alert("AFTER BUTTEN PRESS");</script>';
		if($_POST['duser']=="" || $_POST['dpassword']=="")
		{
			echo '<script>alert("All fields must be filled out");</script>';
		}
		else
		{
			$username=$_POST['duser'];
			$username=test_input($username);
			$password=$_POST['dpassword'];
			$password=test_input($password);

			$r="SELECT demail AND dpass FROM driver WHERE demail='".$username."' and dpass='".$password."'";
			$id="SELECT did FROM driver WHERE demail='".$username."' and dpass='".$password."'";
			$r=mysqli_query($con,$r);
			$kpdid=mysqli_query($con,$id);
			if(mysqli_num_rows($r) > 0)
			{
                        #$did_=mysql_query($con,$id);

				$_SESSION['id']=$username;
				$_SESSION['type']="2";
                        $row = mysqli_fetch_array($kpdid);
                        if($row['did'])
                        {
                             echo"krushna";
                        }
                        $var = $row['did'];
                        $_SESSION["DID"] = $var;
				echo '<script> alert("wellcome to abhi cab" + $var);</script>';
				header('Refresh:0 url=driver.php');
			}
			else
			{
				echo "<script type='text/javascript'>alert('password or email id is not correct..!!!');</script>";
			}

		}
	}

	if(isset($_POST['admin_login_btn']))
	{
		//echo '<script>alert("AFTER BUTTEN PRESS");</script>';
		if($_POST['aname']=="" || $_POST['apassword']=="")
		{
			echo '<script>alert("All fields must be filled out");</script>';
		}
		else
		{
			$username=$_POST['aname'];
			$username=test_input($username);
			$password=$_POST['apassword'];
			$password=test_input($password);

			$r="SELECT aname AND apassword FROM admin WHERE aname='".$username."' and apassword='".$password."'";

			$r=mysqli_query($con,$r);

			if(mysqli_num_rows($r) > 0)
			{
				$_SESSION['id']=$username;
				$_SESSION['type']="3";
				echo '<script>alert("wellcome to abhi cab");</script>';
				header('Refresh:0 url=admin.php');
			}
			else
			{
				echo "<script type='text/javascript'>alert('password or email id is not correct..!!!');</script>";
			}

		}
	}
?>








<!DOCKTYPE html>
<html>
<head>
  <title>Abhi Cab</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!--  <style>
  body {
      background-image: url("images/car.jpg");
      background-repeat: no-repeat;
      background-color: #cccccc;
  }
  </style>-->

  <style>
  .USER {

    min-height: 400px;
    color: #fff;
    padding: 40px 0 0;
    
    margin-top: 130px;
}
.btn{
	
	background: none;
	padding: 10px 20px;
	font-size: 20px;
	font-family: "montserrat";
	cursor:pointer;
	margin: 10px;
	transition: 0.8s;
	position: relative;
	overflow: hidden;
}
.btn1,.btn2{
	color:#ffd700;
	
}
.btn3,.btn4{
	color: #fff;
	background-color: #3498db;
}
.btn1:hover,.btn2:hover{
	color: #fff;
	background-color: #3498db;
	
}
.btn3:hover,.btn4:hover{
	color: #3498db;
	background-color: #fff;
	

}
</style>

<!-- css file style for the pop up form -->
<style>

@import "http://fonts.googleapis.com/css?family=Raleway";

#driver {
    width:100%;
    height:100%;
    opacity:.95;
    top:70;
    left:0;
    display:none;
    position:fixed;
    background-color:#313131;

}
#c {
    width:100%;
    height:100%;
    opacity:.95;
    top:70;
    left:0;
    display:none;
    position:fixed;
    background-color:#313131;

}
#a {
    width:100%;
    height:100%;
    opacity:.95;
    top:70;
    left:0;
    display:none;
    position:fixed;
    background-color:#313131;

}

img#close {
    position:absolute;
    right:-14px;
    top:-14px;
    cursor:pointer
}
div#popupContact {
    position:absolute;
    left:50%;
    top:17%;

    margin-left:-202px;
    font-family:'Raleway',sans-serif
}
form {
    max-width:100%;
    min-width:80%;
    padding:10px 50px;
    border:2px solid gray;
    border-radius:10px;
    font-family:raleway;
    background-color:#fff
}
p {
    margin-top:30px
}
h2 {
    background-color:#FEFFED;
    padding:20px 35px;
    margin:-10px -50px;
    text-align:center;
    border-radius:10px 10px 0 0
}
hr {
    margin:10px -50px;
    border:0;
    border-top:1px solid #ccc
}
input[type=text], input[type=email],input[type=password] {
    width:100%;
    padding:10px;
    margin-top:30px;
    border:1px solid #ccc;
    
    font-size:16px;
    font-family:raleway
}


#Id {
    background-image:url(images/name.jpg);
    background-repeat:no-repeat;
    background-position:5px 7px
}
#Password {
    background-repeat:no-repeat;
    background-position:5px 7px
    margin-bottom:30px
}

#submit {
    text-decoration:none;
    width:100%;
    text-align:center;
    display:block;
    background-color:#FFBC00;
    color:#fff;
    border:1px solid #FFCB00;
    padding:10px 10px;
    font-size:20px;
    cursor:pointer;
    border-radius:5px
}
#submit:hover{
  opacity: 0.8;
  }

span {
    color:red;
    font-weight:700
}
#clocation{
  margin-top: 20%;
  margin-left: 45%;
}
#alocation{
  margin-top: 10%;
  margin-left: 16%;
}
#dlocation{
  margin-top: 20%;
  margin-left: 15%;
}
.footer {
    color: white;
    background-color: black;
    margin-left: 0px;
    text-align: center;
    position:fixed;
    bottom: 0;
    height: 50px;
    width: 100%;
    }
</style>

</head>

<body style="overflow-x:hidden;background-size:100% 100%;background-repeat: no-repeat;bottom: 0;background-attachment: fixed;" background="images/n.jpg" >

<script>

// Validating Empty Field
function check_empty() {
    if (document.getElementById('Id').value == "" || document.getElementById('Password').value == "" ) {
        alert("Fill All Fields !");
    } else {
        document.getElementById('form').submit();
        alert("Form Submitted Successfully...");
    }
}
//Function To Display Popup
function div_show() {
    document.getElementById('driver').style.display = "block";
}
//Function to Hide Popup
function div_hide() {
    document.getElementById('driver').style.display = "none";
}


function div_show_customer() {
    document.getElementById('c').style.display = "block";
}

function div_hide_customer() {
    document.getElementById('c').style.display = "none";
}

function div_show_a() {
    document.getElementById('a').style.display = "block";
}

function div_hide_a() {
    document.getElementById('a').style.display = "none";
}

function login() {
	alert("Please login to book your cab");
}
</script>

  <div id="krushna">
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="padding: 0px margin:0px">
  <center>
  	<h1 align="left" style="margin-left:10px;" ><font color="white" size="15">  WELCOME TO ABHI CAB</font>
  	<img src="images/logo.png" alt="google.com" width="100" height="50" align="right" style="margin-right:10px;">
  	</h1>
  </center>
  <div class="main" >
    <ul class="nav navbar-nav navbar-right" style="margin-right:10px;">
      <li class="active">
        <a href="index.php"> Home   <span class="glyphicon glyphicon-home"></span></a>
      </li>
		<!--<li >
        <li  ><a class="dropdown-toggle" data-toggle="dropdown" href="#">Login <span class="caret"></span></a>
				<ul class="dropdown-menu" >
          <li align="right"><a href="index.php">Customer  <span class="glyphicon glyphicon-user"></span></a></li>
          <li align="right"><a href="index.php">Admin  <span class="glyphicon glyphicon-user"></span></a></li>
          <li align="right"><a href="index.php">Driver  <span class="glyphicon glyphicon-user"></span></a></li>
				</ul>
			</li>
		</li>-->
      <li onclick="login()"> <a href="#">Book Now  <span class="glyphicon glyphicon-shopping-cart"></span></a></li>
      <li><a href="about_us.php">About Us</a></li>
      <li><a href="contact.php">Contact Us <span class="glyphicon glyphicon-earphone"></span></a></li>
	</ul>
  </div>
 </nav>
</div>



 
<div>
  <div class="btn-group" id = "dlocation">
    <button type="button" class="btn btn1 " data-toggle="dropdown">
      <font size="15"><b>Driver</b>
      </font>
    </button>
    <ul class="dropdown-menu" role="menu" align="right" >
      <li id="popup" onclick="div_show()" align="right"><a href="#">Log In<span class="glyphicon glyphicon-user"></span></a></li>
      <li align="right"><a href="driver_sign_up.php">Sign Up<span class="glyphicon glyphicon-user"></span></a></li>
    </ul>
  </div>
   

 
<!--
  <div class="btn-group" id = "alocation">
    <button type="button" class="btn btn1" data-toggle="dropdown">
      <font size="15"><b>Admin</b>
      </font>
    </button>
      <ul class="dropdown-menu" role="menu" align="right" >
      <li id="popup" onclick="div_show_a()" align="right"><a href="#">Log In<span class="glyphicon glyphicon-user"></span></a></li>
    </ul>
    
  </div>-->



   <div class="btn-group" id = "clocation">
    <button type="button" class="btn btn1 " data-toggle="dropdown">
      <font size="15"><b>Customer</b>
      </font>
    </button>
    <ul class="dropdown-menu" role="menu" align="right" >
      <li id="popup" onclick="div_show_customer()"align="right"><a href="#">Login<span class="glyphicon glyphicon-user"></span></a></li>
      <li align="right"><a href="customer_sign_up.php">Sign Up<span class="glyphicon glyphicon-user"></span></a></li>
    </ul>
  </div>
</div>


   <!--<ul class="options" style="margin-right:100px; margin-top:150px; float:right;">

     <li class="dropdown" align="right"><a class="dropdown-toggle" data-toggle="dropdown" href="#"><font color="yellow"size="15">
    	Customer
     	<span class="caret"></span><span class="glyphicon glyphicon-user"></span></a></font>
		<ul class="dropdown-menu" >
     		<li id="popup" onclick="div_show_customer()"align="right"><a href="#">Login<span class="glyphicon glyphicon-user"></span></a>
     		<li align="right"><a href="customer_sign_up.php">Sign In  <span class="glyphicon glyphicon-user"></span></a></li>
     	</ul>
     </li>

     <li id="popup" onclick="div_show_a()"align="right" style="margin-right:5px;"><a class="dropdown-toggle" data-toggle="dropdown" href="#"><font color="yellow" size="15">Admin<span class="glyphicon glyphicon-user"></span></font></li>

     <li class="dropdown" align="right"><a class="dropdown-toggle" data-toggle="dropdown" href="#"><font color="yellow" size="15">
    	Driver
     	<span class="caret"></span><span class="glyphicon glyphicon-user"></span></a></font>
		<ul class="dropdown-menu" >
     		<li id="popup" onclick="div_show()"align="right"><a href="#">Login<span class="glyphicon glyphicon-user"></span></a>
     		</li>
     		<li align="right"><a href="driver_sign_up.php">Sign In  <span class="glyphicon glyphicon-user"></span></a></li>
     	</ul>
     </li>
   </ul>-->
 


<!-- Footer -->
  <footer class="footer">
    <h5>Copyright &copy; 2019 AbhiCab.com</h5>
  </footer>
</div>

<div id="driver" >
	<!-- Popup Div Starts Here -->
	<div id="popupContact">

		<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"  id="form" method="post" name="form">
		<img id="close" src="images/3.png" onclick ="div_hide()">
        <h2>Driver login</h2>
        <hr>
        <lable><b>Username</b></lable>
        <input type="text" placeholder="Enter Username" name="duser" required>
        <br></br>
        <lable><b>Password</b></lable>
        <input id="Password" name="dpassword" placeholder="Password" type="password" text-type="password">
        <br></br>
        <button style="width:100%;" align="center" name="driver_login_btn" id="submit">Login</button>
	    </form>
    </div>
    <!-- Popup Div Ends Here -->
</div>

<div id="c" >
	<!-- Popup Div Starts Here -->
	<div id="popupContact">

		<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"  method="post" name="form">
		<img id="close" src="images/3.png" onclick ="div_hide_customer()">
        <h2>Customer login</h2>
        <hr>
        <lable><b>Username</b></lable>
        <input type="text" placeholder="Enter Username" name="cuser" required>
        <br></br>
        <lable><b>Password</b></lable>
        <input id="Password" name="cpassword" placeholder="Password" type="password" text-type="password">
        <br></br>
        <button type="submit" style="width:100%;" align="center" name="customer_login_btn" id="submit" >Login</button>
	    </form>
    </div>
    <!-- Popup Div Ends Here -->
</div>

<div id="a" >
	<!-- Popup Div Starts Here -->
	<div id="popupContact">

		<form action="#" id="form" method="post" name="form">
		<img id="close" src="images/3.png" onclick ="div_hide_a()">
        <h2>Admin login</h2>
        <hr>
        <lable><b>Username</b></lable>
        <input type="text" placeholder="Enter Username" name="aname" required>
        <br></br>
        <lable><b>Password</b></lable>
        <input id="Password" name="apassword" placeholder="Password" type="password" text-type="password">
        <br></br>
        <button style="width:100%;" align="center" name="admin_login_btn" id="submit">Login</a></button>
	    </form>
    </div>
    <!-- Popup Div Ends Here -->
</div>



</body>
</html>
