<?php session_start(); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Professeurs</title>
<link rel="stylesheet" href="w3.css">

</head>

<body bgcolor="#D7FFFD">
<table  class="w3-table w3-striped w3-bordered" width="329" border="0" align="left">
 <form method="post" action="menuprof.php" class="w3-container">
  <tr>
    <td align="center"><span class="gcolor"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN">
      <br />
Accès réservé aux personnes autorisées:<br /> 
Identifiez vous ! </span></td>
  </tr>
  <tr>
    <td width="323" align="left" style="text-align: left"><span class="gcolor"> 
        <label class="w3-select w3-border w3-light-grey">Nom de l'utilisateur : </label>        
        <input class="w3-input" type="text" name="login" onclick="this.value=''"/>    
    </span></td>
  </tr>
  <tr>
    <td align="left" style="text-align: left"><span class="gcolor">
        <label>Mot de passe: </label>        
        <input class="w3-input" type="password" name="pass" onclick="this.value=''"/>    
    </span></td>
  </tr>
  <tr>
    <td align="center"><span class="menu">      
      <input class="w3-input" type="submit"  name="envoi" value="Entrer" style="font-size:9px"/>    
    </span></td>
  </tr></form>
  </table>
 <?php

if(isset($_POST['envoi'])){
$login=$_POST['login'];
$pass=$_POST['pass'];
include("_serveur.php");
$sql = 'SELECT * FROM users where username= "'.$login.'" and password="'.$pass.'" and  type=2';
if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
$req=mysqli_query($link, $sql);
if ($data = mysqli_fetch_array($req)) 
 {
 $id=$data['id'];
 $_SESSION['id']=$id;
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=menuprofsadmin.php">';    

}
}
?>
</body>
</html>