Advertisement
Guest User

5

a guest
Apr 3rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <?php include('header.php'); ?>
  2.  
  3. <?php
  4.  
  5. ?>
  6. <!DOCTYPE html>
  7. <html>
  8. <head>
  9. <meta charset="utf-8">
  10. <title>Login</title>
  11. <link rel="stylesheet" href="css/style.css" />
  12. </head>
  13. <body>
  14. <?php
  15. require('dbconnect.php');
  16. session_start();
  17. // If form submitted, insert values into the database.
  18. if (isset($_POST['username'])){
  19.  
  20. $username = stripslashes($_REQUEST['username']); // removes backslashes
  21. $username = mysqli_real_escape_string($db,$username); //escapes special characters in a string
  22. $password = stripslashes($_REQUEST['password']);
  23. $password = mysqli_real_escape_string($db,$password);
  24.  
  25. //Checking is user existing in the database or not
  26. $query = "SELECT * FROM medewerker WHERE gebruikersnaam = '$username' and wachtwoord = '$password'";
  27. $result = mysqli_query($db,$query) or die(mysql_error());
  28. $rows = mysqli_num_rows($result);
  29. if($rows==1){
  30. $_SESSION['username'] = $username;
  31. header("Location: dashboard.php"); // Redirect user to index.php
  32. }else{
  33. echo "<div class='form'><h3>Gebruikersnaam of wachtwoord kloppen niet.</h3><br/>Ga terug <a href='index.php'>Inloggen</a></div>";
  34. }
  35. }else{
  36. ?>
  37. <div class="form">
  38. <h1>Log In</h1>
  39. <form action="" method="post" name="login">
  40. Gebruikersnaam:
  41. <input type="text" name="username" placeholder="Username" required />
  42. <br>
  43. Wachtwoord:
  44. <input type="password" name="password" placeholder="Password" required />
  45. <input name="submit" type="submit" value="Inloggen" />
  46. </form>
  47.  
  48. <?php } ?>
  49.  
  50.  
  51. </body>
  52. </html>
  53.  
  54.  
  55. <?php include('footer.php'); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement