<?php session_start();
include("../header.php");
include("../dbconnection.php");
?>
<div class="container">
	 <div id="loginbox" style="display:block;margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">                    
            <div class="panel panel-info" >
                    <div class="panel-heading">
                        <div class="panel-title">Sign In</div>
                        <div style="float:right; font-size: 80%; position: relative; top:-10px"><a href="#">Forgot password?</a></div>
                    </div>     

                    <div style="padding-top:30px" class="panel-body" >

                        <div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
                            
                        <form id="loginform" name="form" class="form-horizontal" role="form" method="post" action="">
                                    
                            <div style="margin-bottom: 25px" class="input-group">
                                        <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                                        <input id="login-username" type="text" class="form-control" name="username" placeholder="username">                                        
                                    </div>
                                
                            <div style="margin-bottom: 25px" class="input-group">
                                        <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
                                        <input id="login-password" type="password" class="form-control" name="password" placeholder="password">
                                    </div>
                                    

                                
                            <div class="input-group">
                                      <div class="checkbox">
                                        <label>
                                          <input id="login-remember" type="checkbox" name="rememberme" value="1"> Remember me
                                        </label>
                                      </div>
                                    </div>


                                <div style="margin-top:10px" class="form-group">
                                    <!-- Button -->

                                    <div class="col-sm-12 controls">
                                   <input type="submit" name="submit"  value="Login" id="btn-login" class="btn btn-success"  />
									<button id="lft" type="button" class="btn btn-error"><i class="icon-hand-right"></i><a href="index.html"> &nbsp Cancel </a></button>
                  

                                    </div>
                                </div>
								

                                <div class="form-group">
                                    <div class="col-md-12 control">
                                        <div style="border-top: 1px solid#888; padding-top:15px; font-size:85%" >
                                            Don't have an account! 
                                        <a href="signup.php" >  &nbsp;&nbsp; Sign Up Here
                                        </a>
                                        </div>
                                    </div>
                                </div>    
                            </form>     
							<?php

     
    if(isset($_POST['submit'])){
		
		
		 $username = $_POST['username'];   
		 $password = $_POST['password']; 
		 
		 
		 $query = mysql_query("select * from customer where username = '$username' and password = '$password' and type='normal' ") or die (mysql_error());
		 $nums = mysql_num_rows($query);
		 $rows = mysql_fetch_array($query);
		 
		 if ($nums > 0)
		 {
			 $id = $rows['customer_id'];
			 
			 $_SESSION['id'] = $rows['customer_id'];
			 
		?>
		<script>
		window.location="homepage.php";
		</script>
		<?php
		 }
		 else
		 {
			 echo ' <div class="col-md-offset-3 col-md-9">
                      <button id="btn-signup" type="button" class="btn btn-error"><i class="icon-hand-right"></i>Invalid Username and Password! </button>
                                         
                    </div>';
		 }
	}

?>


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

