1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
| <?php
session_start();
if((isset($_SESSION['id']) != "" )){
header("Location : home.php");
exit();
}
include 'Dbconnect.php';
if(isset($_POST['login'])) {
if(isset($_POST['cnx']) && $_POST['cnx'] == "user"){
$email = $_POST['email'];
$password = $_POST['password'];
$result = $con->query("SELECT * FROM users WHERE email = '" . $email. "' and password = '" . md5($password) . "' AND confirme=1");
if ($row = $result->fetch()) {
$_SESSION['id'] = $row['id'];
$_SESSION['name'] = $row['name'];
header("Location: home.php");
} else {
$errormsg = "Le mot de passe que vous avez indiqué nest pas valable";
}
if(isset($_POST['souvenir'])){
setcookie('email','$email',time()+356*24*3600,null,null,false,true);
setcookie('password','$password',time()+356*24*3600,null,null,false,true);
}
}elseif (isset($_POST['cnx']) && $_POST['cnx'] == "admin") {
$email = $_POST['email'];
$password = $_POST['password'];
$resultat = $con->query("SELECT * FROM users WHERE email = '" . $email. "' and password = '" . md5($password) . "' AND role = 'admin'");
if ($row = $resultat->fetch()) {
$_SESSION['id'] = $row['id'];
$_SESSION['nom'] = $row['nom'];
header("Location: home_admin.php");
} else {
$errormsg = "Le mot de passe que vous avez indiqué nest pas valable";
}
if(isset($_POST['souvenir'])){
setcookie('email','$email',time()+356*24*3600,null,null,false,true);
setcookie('password','$password',time()+356*24*3600,null,null,false,true);
}
}
}
?>
<!doctype html>
<html>
<head>
<title>Se connecter!</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport" >
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="stylee.css">
</head>
<body class="imag">
<h2 id="titre">Gestion des Salle d'informatique</h2>
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- menu items -->
<div class="collapse navbar-collapse" id="navbar1">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="login.php">Se Connecter</a></li>
<li><a href="compte.php">S'inscrire</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row" id="demo" style="margin-top: -35px;">
<div class="col-md-4 col-md-offset-4 well">
<form role="form" action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="loginform">
<fieldset>
<legend><img src="connexion.jpg" id="p"></legend>
<div class="form-group">
<label>Se Connecter en tant que :</label>
<select name= "cnx">
<option value="user">Utilisateur</option>
<option value="admin">Super Administrateur</option>
</select>
</div>
<div class="form-group">
<label for="name">Email</label>
<input type="text" name="email" placeholder="Votre Email" required class="form-control" />
</div>
<div class="form-group">
<label for="name">Mot de Passe</label>
<input type="password" name="password" placeholder="Votre Mot de Passe" required class="form-control" />
</div>
<div class="form-group">
<input type="submit" name="login" value="Se Connecter" class="btn btn-primary" />
<input type="checkbox" name="souvenir">Se Souvenir de Moi
</div>
</fieldset>
</form>
<span class="text-danger"><?php if (isset($errormsg)) { echo $errormsg; } ?></span>
</div>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4 text-center">
Nouveau utilisateur ? <a href="compte.php" style="color: blue;">S'inscrire ici</a>
</div>
</div>
</div>
<script src="js/bootstrap.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html> |
Partager