Advertisement
Guest User

men

a guest
Oct 2nd, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.07 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.         {
  12.             echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" class="navbar-form navbar-right inline-form">'; ?>
  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><?php
  18.         }
  19.         elseif (!isset($_POST['uservalid']))
  20.         {
  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><?php
  35.             }
  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.                 <div class="form-group has-warning has-feedback">
  40.                     <label class="control-label" for="idWarning">Veuillez remplir tous les champs</label>
  41.                     <input type="text" class="input-sm form-control" id="idWarning" name="user" placeholder="Nom d'utilisateur">
  42.                     <span class="glyphicon glyphicon-warning-sign form-control-feedback"></span>
  43.                 </div>
  44.                 <div class="form-group has-warning has-feedback">
  45.                     <input type="password" class="input-sm form-control" id="idWarning" name="password" placeholder="Mot de passe">
  46.                     <span class="glyphicon glyphicon-warning-sign form-control-feedback"></span>
  47.                 </div>
  48.                 <button type="submit" class="btn btn-danger btn-sm" name="uservalid">Connexion <span class="glyphicon glyphicon-chevron-right"></span> </button><?php
  49.             }
  50.             else
  51.             {
  52.                 echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" class="navbar-form navbar-right inline-form">'; ?>
  53.                 <div class="form-group"><input type="text" class="input-sm form-control" name="user" placeholder="Nom d'utilisateur"></div>
  54.                 <div class="form-group"><input type="password" class="input-sm form-control" name="password" placeholder="Mot de passe"></div>
  55.                 <button type="submit" class="btn btn-danger btn-sm" name="uservalid">Connexion <span class="glyphicon glyphicon-chevron-right"></span> </button> <?php
  56.             }
  57.             echo '</form>';
  58.         }
  59.         if (!isset($_SESSION["pseudo"]) AND (isset($_POST['uservalid'])))
  60.         {
  61.             $pass_hache = sha1($_POST['password']);
  62.             $req = $bdd->prepare('SELECT id FROM admin WHERE user = :user AND password = :password');
  63.             $req->execute(array(
  64.                 'user' => $_POST["user"],
  65.                 'password' => $pass_hache));
  66.             $resultat = $req->fetch();
  67.             if ($resultat)
  68.             {
  69.                 $_SESSION['id'] = $resultat['id'];
  70.                 $_SESSION['pseudo'] = $_POST["user"];
  71.                 header("Refresh:0");
  72.             }
  73.             elseif ((empty($_POST["user"]) OR (empty($_POST["password"]))) OR (empty($_POST["user"]) AND (empty($_POST["password"]))))
  74.             {
  75.                 header('Location: '.$_SERVER['PHP_SELF'].'?error=missing-field');
  76.             }
  77.             elseif (!$resultat) {
  78.                 header('Location: '.$_SERVER['PHP_SELF'].'?error=wrong-password');
  79.             }
  80.         }
  81.         if (isset($_POST["deco"]))
  82.         {
  83.             session_destroy();
  84.             header("Refresh:0");
  85.         }
  86.         ?>
  87.     </div>
  88. </nav>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement