<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Pré-Inscription</title>

    <!-- Bootstrap -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
    <!-- Animate.css -->
    <link href="../vendors/animate.css/animate.min.css" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="../build/css/custom.min.css" rel="stylesheet">
  </head>

  <body class="login">
    <div>
      <a class="hiddenanchor" id="signup"></a>
      <a class="hiddenanchor" id="signin"></a>

      <div class="login_wrapper">
        <div class="animate form login_form">
          <section class="login_content">
            <form action="" method="POST">
              <h1>Login Form</h1>
              <div>
                <input type="text" class="form-control" placeholder="Username" name="username" required="" />
              </div>
              <div>
                <input type="password" class="form-control" placeholder="Password" name="password" required="" />
              </div>
 
			  
        
			<input type="submit" name="btn_login" value="Vérifier" class="btn btn-info" tabindex="7">   
			<input type="submit" name="reset" value="Annuler" class="btn btn-info" tabindex="7">   
			  
			
		
 

              

              <div class="clearfix"></div>

              <div class="separator">

                <br />

                <div>
                  <h1><i class="fa fa-paw"></i> Pré-Inscription!</h1>
                  <p>Computer Service of the University of Burundi</p>
				  
				 <p>  <a href='../index.php'>Retour </a> <p> </p>
				  
                </div>
              </div>
            </form>
          </section>
        </div>
      </div>
    </div>
  </body>
</html>

<?php
try
{
   $pdo = new PDO('mysql:host=localhost; dbname=dbvalidationinscription', 'root','');
   //echo 'Connection Successfull';
}
catch(PDOException $error)
{
   echo $error->getmessage();
}
session_start();
if(isset($_POST['btn_login']))
{
	
    $username = $_POST['username'];
    $password = $_POST['password'];
	
	
    $select = $pdo->prepare("select * from users where password='$password' AND username='$username'");
    $select->execute();
    $row = $select->fetch(PDO::FETCH_ASSOC);
	

    if($row['username']=='Admin')
    {
        $_SESSION['username']=$row['username'];
 
        
       echo "<script type='text/javascript'>alert('Connection Successfull');</script>";
			  echo "<script>document.location='index.php'</script>";  
    }
   else if($row['username']=='User')
		{	

		 echo "<script type='text/javascript'>alert('Connection Successfull');</script>";
			  echo "<script>document.location='user.php'</script>"; 
		}
     else
	 {
	echo "<script type='text/javascript'>alert('Connection failed!!! email or password incorrect.Try aigan');</script>";
		echo "<script>document.location='login.php'</script>";  
	 }
  
    
}
?>

