Advertisement
Guest User

menu

a guest
Oct 2nd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.14 KB | None | 0 0
  1. <nav class="navbar navbar-inverse">
  2.     <div class="container-fluid">
  3.         <a class="navbar-brand" href="index.php">E-Sport STI <span class="glyphicon glyphicon-headphones"></span></a>
  4.         <ul class="nav navbar-nav">
  5.             <li class="active"> <a href="index.php">Accueil</a> </li>
  6.             <li> <a href="liste.php">Liste</a> </li>
  7.             <li> <a href="rechercher.php">Recherche</a> </li>
  8.         </ul>
  9.         <?php
  10.         if (isset($_SESSION["pseudo"])) {
  11.             echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" class="navbar-form navbar-right inline-form">';
  12.             ?>
  13.             <div class="form-group">
  14.             <div class="swagggg input-sm form-control "> Bonjour, <?php echo $_SESSION["pseudo"] ?></div>
  15.             <button type="submit" class="btn btn-danger btn-sm" name="deco"><span class="glyphicon glyphicon-chevron-left"></span>Déconnexion</button>
  16.             </div>
  17.             </form>
  18.         <?php
  19.         }
  20.         elseif (!isset($_POST['uservalid'])) {
  21.             if ((!empty($_GET['error'])) AND (($_GET['error']=="wrong-password")))
  22.             {
  23.             echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" class="navbar-form navbar-right inline-form">';
  24.             ?>
  25.             <div class="form-group has-error has-feedback">
  26.                 <label class="control-label" for="idError">Nom d'utilisateur ou mdp incorrect</label>
  27.                 <input type="text" class="input-sm form-control" id="idError" name="user" placeholder="Nom d'utilisateur">
  28.                 <span class="glyphicon glyphicon-remove form-control-feedback"></span>
  29.             </div>
  30.             <div class="form-group has-error has-feedback">
  31.                 <input type="password" class="input-sm form-control" id="idError" name="password" placeholder="Mot de passe">
  32.                 <span class="glyphicon glyphicon-remove form-control-feedback"></span>
  33.             </div>
  34.                 <button type="submit" class="btn btn-danger btn-sm" name="uservalid">Connexion <span class="glyphicon glyphicon-chevron-right"></span> </button>
  35.             <?php    }
  36.             elseif ((!empty($_GET['error'])) AND (($_GET['error']=="missing-field")))
  37.             {
  38.                 echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" class="navbar-form navbar-right inline-form">';
  39.                 ?>
  40.                 <div class="form-group has-warning has-feedback">
  41.                     <label class="control-label" for="idWarning">Veuillez remplir tous les champs</label>
  42.                     <input type="text" class="input-sm form-control" id="idWarning" name="user" placeholder="Nom d'utilisateur">
  43.                     <span class="glyphicon glyphicon-warning-sign form-control-feedback"></span>
  44.                 </div>
  45.                 <div class="form-group has-warning has-feedback">
  46.                     <input type="password" class="input-sm form-control" id="idWarning" name="password" placeholder="Mot de passe">
  47.                     <span class="glyphicon glyphicon-warning-sign form-control-feedback"></span>
  48.                 </div>
  49.                 <button type="submit" class="btn btn-danger btn-sm" name="uservalid">Connexion <span class="glyphicon glyphicon-chevron-right"></span> </button>
  50.             <?php    }
  51.             else
  52.             {
  53.                 echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" class="navbar-form navbar-right inline-form">';
  54.                 ?>
  55.                 <div class="form-group">
  56.                     <input type="text" class="input-sm form-control" name="user" placeholder="Nom d'utilisateur">
  57.                 </div>
  58.                 <div class="form-group">
  59.                     <input type="password" class="input-sm form-control" name="password" placeholder="Mot de passe">
  60.                 </div>
  61.                 <button type="submit" class="btn btn-danger btn-sm" name="uservalid">Connexion <span class="glyphicon glyphicon-chevron-right"></span> </button>
  62.             <?php    }
  63.             echo '</form>'; } ?>
  64.         <?php
  65.         if (!isset($_SESSION["pseudo"]) AND (isset($_POST['uservalid']))) {
  66.             $pass_hache = sha1($_POST['password']);
  67.             $req = $bdd->prepare('SELECT id FROM admin WHERE user = :user AND password = :password');
  68.             $req->execute(array(
  69.                 'user' => $_POST["user"],
  70.                 'password' => $pass_hache));
  71.             $resultat = $req->fetch();
  72.             if ($resultat)
  73.             {
  74.                 $_SESSION['id'] = $resultat['id'];
  75.                 $_SESSION['pseudo'] = $_POST["user"];
  76.                 header("Refresh:0");
  77.             }
  78.             elseif ((empty($_POST["user"]) OR (empty($_POST["password"]))) OR (empty($_POST["user"]) AND (empty($_POST["password"]))))
  79.             {
  80.                 header('Location: '.$_SERVER['PHP_SELF'].'?error=missing-field');
  81.             }
  82.             elseif (!$resultat) {
  83.                 header('Location: '.$_SERVER['PHP_SELF'].'?error=wrong-password');
  84.             }
  85.         }
  86.         if (isset($_POST["deco"])) {
  87.             session_destroy();
  88.             header("Refresh:0");
  89.         }
  90.         ?>
  91.     </div>
  92. </nav>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement