Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. <?php
  2. session_start();
  3. ?>
  4. <!DOCTYPE html>
  5. <html>
  6.     <head>
  7.         <style>
  8.         table, th, td {
  9.             border: 1px solid black;
  10.         }
  11.         </style>
  12.     </head>
  13. <body>
  14.     <?php
  15.         unset($_SESSION['Error']);
  16.         unset($_SESSION['Welcome']);
  17.         $username = filter_input(INPUT_POST,'username');
  18.         $usernameF = $username;
  19.         $username = strtolower($username);
  20.         $password = filter_input(INPUT_POST,'password');
  21.         $servername = "localhost";
  22.         $dbusername = "root";
  23.         $dbpassword = "";
  24.         $dbname = "gamingbuddy";
  25.  
  26.         // Create connection
  27.         $conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
  28.         // Check connection
  29.         if ($conn->connect_error) {
  30.             die("Connection failed: " . $conn->connect_error);
  31.         }
  32.  
  33.         $sql = "SELECT password FROM gb_account WHERE gb_Account.Username LIKE '$username'";
  34.         $result = $conn->query($sql);
  35.  
  36.  
  37.         echo "<p>". $password . "</p>";
  38.         if ($result->num_rows > 0) {
  39.             while($row = $result->fetch_assoc()) {
  40.                 echo "<p>" . $row["password"] . "</p>";
  41.                 if(password_verify($password,$row["password"])){
  42.                     $_SESSION["Welcome"] = "Welkom ".$usernameF;
  43.                 }
  44.                 else{
  45.                     $_SESSION["Error"] = "De gebruikersnaam/wachtwoord combinatie is ongeldig.";
  46.                 }
  47.             }
  48.         }
  49.         else {
  50.             $_SESSION["Error"] = "De gebruikersnaam/wachtwoord combinatie is ongeldig.";
  51.         }
  52.  
  53.     $conn->close();
  54.     header("Location: index.php");
  55.     exit;
  56.     ?>
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement