<style>

body {
background-repeat:no-repeat;
background-size: cover; 
}
</style>
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>

<?php
$a = mt_rand(0,17); 

echo'<body background="../images/fonds/'.$a.'.jpg" background="cover">';

include ('../master.php');
$GLOBAL_TITRE.="Espace Admin - Identification";
echo '
	<link rel="stylesheet" href="../style/axa.css">
</head><body>
<form action="login.php" method="post">
<center>



<div style="max-width: 50%; margin: 15% auto 10px;" class="well">

    <h1>
        <div class="panel panel-danger"><div class="panel-heading"><strong>Espace admin<strong></div></div>
    </h1>
<form class="form-horizontal" role="form" name="form" action="" method="post">
    <div class="form-group">
        <label for="inputEmail1" class="col-sm-4 control-label">Nom utilisateur</label>
        <div class="col-sm-20">
            <input type="text" name="login" id="login" class="form-control" placeholder="Identifiant">
        </div>
    </div>
    <div class="form-group">
        <label for="inputPassword1" class="col-sm-4 control-label">Mot de passe</label>
        <div class="col-sm-20">
            <input input type="password" name="password" id="password" class="form-control" placeholder="Mot de passe">
        </div>
    </div>
    
    <div class="form-group">
        <div class="col-sm-offset-4 col-sm-40">
            <button type="submit" class="btn  btn-lg btn-primary"><i class="icon icon-check icon-lg"></i> Connexion </button>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
           <a href="../"> <button type="button" class="btn btn-lg btn-default">Retour</button></a>

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



</div>
';

if (isset($_POST["login"])){
	$login=trim($_POST["login"]);
	$sql="SELECT id, type, login FROM utilisateurs WHERE 
		login='".mysql_escape_string($login)."' AND 
		password='".mysql_escape_string(trim($_POST["password"]))."' AND
		type IN(1)
		";
	$result=mysql_query($sql, $link);
	if (mysql_num_rows($result)==1) {
		if (SID!="") {
			echo '<tr><td class="white" bgcolor="#FAFAFA" colspan="2" align="center">
			<font class="sub">
			La connexion a échoué car votre<br />
			navigateur est configuré pour<br />
			refuser les cookies de sessions.<br/>
			Merci de changer les paramètres de <br />
			votre navigateur pour vous connecter.</font></td></tr>';
			}
		else {
			$_SESSION["SS_user_id"]=mysql_result($result,0, "id");
			$_SESSION["SS_user_type"]=mysql_result($result, 0, "type");
			$_SESSION["SS_user_nom"]=mysql_result($result, 0, "login");
			$_SESSION["SS_session_online"]="true";
			//echo '<b>Bonjour '.$_SESSION["SS_user_nom"].', </b></font><br><br><a href="'.$FROM_GLOBAL.'">Cliquez ici pour vous connecter.</a>';
			kick_me("index.php");//substr($_SERVER["PHP_SELF"], 0, strrpos($_SERVER["PHP_SELF"], "/"))
			}
		}
	else{
		echo '<tr><td class="white" bgcolor="#FAFAFA" colspan="2" align="center"><font class="sub">Nom d\'utilisateur ou mot de passe invalide.</font></td></tr>';
		}
	}
echo '

</center>
</form>
</body>
</html>
';
?>
