Advertisement
Guest User

Untitled

a guest
May 28th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Autoroute | Connexion</title>
  5. <meta charset="utf-8">
  6. <style>
  7. .error{color: #b90000;}
  8. .valid{color: #31a765;}
  9. </style>
  10. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  11. </head>
  12. <body>
  13.  
  14. <?php
  15.  
  16. require_once("header.php");
  17.  
  18.  
  19.  
  20. $username = $password = "";
  21. $test="";
  22.  
  23. if ($_SERVER["REQUEST_METHOD"]=="POST") {
  24.  
  25. $username=$_POST["username"];
  26. $password=$_POST["password"];
  27.  
  28. }
  29.  
  30.  
  31. ?>
  32.  
  33.  
  34. <div class="container">
  35. <div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
  36. <div class="panel panel-info" >
  37. <div class="panel-heading">
  38. <div class="panel-title">Se connecter</div>
  39. </div>
  40.  
  41. <div style="padding-top:30px" class="panel-body" >
  42.  
  43. <div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
  44.  
  45. <form id="loginform" class="form-horizontal" role="form" method="post">
  46.  
  47. <div style="margin-bottom: 25px" class="input-group">
  48. <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
  49. <input id="login-username" type="text" class="form-control" name="username" placeholder="Nom d'utilisateur">
  50. </div>
  51.  
  52. <div style="margin-bottom: 25px" class="input-group">
  53. <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
  54. <input id="login-password" type="password" class="form-control" name="password" placeholder="Mot de passe">
  55. </div>
  56.  
  57. <div style="margin-top:10px" class="form-group">
  58. <div class="col-md-offset-3 col-md-9">
  59. <button id="btn-signup" name="submit" type="submit" value="submit" class="btn btn-info"><i class="icon-hand-right"></i>Connexion</button>
  60. </div>
  61. </div>
  62.  
  63. <div class="form-group">
  64. <div class="col-md-12 control">
  65. <div style="border-top: 1px solid#888; padding-top:15px; font-size:85%" >
  66. Vous n'avez pas de compte ?
  67. <a href="SignUp.php" onClick="$('#loginbox').hide(); $('#signupbox').show()">
  68. Inscrivez-vous ici !
  69. </a>
  70. </div>
  71. </div>
  72. </div>
  73. </form>
  74.  
  75.  
  76.  
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81.  
  82. <?php
  83.  
  84. if (isset($_POST['submit'])!="") {
  85.  
  86. if ($username!="" && $password!="") {
  87.  
  88. $username=$_POST["username"];
  89. $password=hash('sha256',$_POST["password"]);
  90.  
  91. $request = $bdd->prepare('SELECT * FROM users WHERE Username = :username AND Password = :password');
  92. $request->execute(array(
  93. 'username' => $username,
  94. 'password' => $password
  95. ));
  96. $data = $request->fetch();
  97.  
  98. if ($data['Username']==$username && $data['Password']==$password) {
  99. $_SESSION['user']=$data['FirstName'];
  100.  
  101. if($data['admin']==1) {
  102. $_SESSION['admin'] = 1;
  103. ?>
  104. <br><br><h3 align="center"><span
  105. class="valid">Connexion admin ! Bienvenue <?php echo $data['FirstName'] . " " . $data['LastName']; ?></span>
  106. </h3>
  107. <?php if (headers_sent()) {
  108. ?>
  109. <h3 align="center"><?php die("Cliquez <a href=index.php>ici</a> sur ce lien pour continuer"); ?></h3>
  110. <?php }
  111. else{
  112. exit(header("Location: index.php"));
  113. }
  114. }
  115. else {
  116. $_SESSION['admin']=0;
  117. ?>
  118. <br><br><h3 align="center"><span class="valid">Connexion client ! Bienvenue <?php echo $data['FirstName']." ".$data['LastName'];?></span></h3>
  119. <?php
  120. if (headers_sent()) {
  121. ?><h3 align="center"><?php die("Cliquez <a href=DBaccess.php>ici</a> sur ce lien pour continuer");?></h3>
  122. <?php }
  123. else{
  124. exit(header("Location: DBaccess.php"));
  125. }
  126. }
  127.  
  128.  
  129. }
  130. else {?>
  131. <br><br><h3 align="center"><span class="error">Nom utilisateur ou mot de passe incorrect</span></h3>
  132. <?php }
  133.  
  134.  
  135.  
  136.  
  137. }
  138. else {
  139. ?>
  140. <br><br><h3 align="center"><span class="error">Remplir tout le formulaire</span></h3>
  141. <?php }
  142. }
  143.  
  144. ?>
  145. </body>
  146. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement