Advertisement
Guest User

Untitled

a guest
Mar 13th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. require('dbconnect.php');
  5.  
  6. //$query = "SELECT wachtwoord FROM gebruikers WHERE username = $username";
  7.  
  8. if(isset($_POST['login_button'])) {
  9. if(isset($_POST['gebruikersnaam']) && isset($_POST['wachtwoord'])) {
  10. $username = $_POST['gebruikersnaam'];
  11. $password = $_POST['wachtwoord'];
  12. $tempPassword = hash ('sha512', $password);
  13.  
  14. $query = "SELECT * FROM gebruikers WHERE gebruikersnaam = '$username' AND wachtwoord = '$tempPassword'";
  15.  
  16. $result = mysql_query($query) or die(mysql_error());
  17. $count = mysql_num_rows($result);
  18.  
  19. if($count == 1) {
  20. $_SESSION['gebruikersnaam'] = $username;
  21. }
  22.  
  23. else {
  24. echo "Wrong username or password.";
  25. }
  26. }
  27. }
  28.  
  29. if(isset($_SESSION['gebruikersnaam'])) {
  30. $gebruikersnaam = $_SESSION['gebruikersnaam'];
  31. echo '<div id="ingelogd">';
  32. echo 'Welkom '.$gebruikersnaam.'<br />';
  33. echo '<a href="logout.php"> <input type="submit" name="logout" value="Log out"> </a>';
  34. echo '</div>';
  35. }
  36.  
  37.  
  38.  
  39. ?>
  40.  
  41. <!DOCTYPE html>
  42. <html>
  43. <body>
  44. <?php if (!isset($_SESSION['gebruikersnaam'])) { ?>
  45. <form method="POST" action="">
  46. <input type="text" name="gebruikersnaam" placeholder="Gebruikersnaam">
  47. <br>
  48. <input type="password" name="wachtwoord" placeholder="Wachtwoord">
  49. <input type="submit" name="login_button" value="Log in">
  50. <br>
  51. <input type="checkbox" name="onthouden" value="onthouden">
  52. Onthouden &nbsp; <a href="registreren.php" class="login">Registeren</a>&nbsp; &nbsp;<a href="#" class="login">Wachtwoord vergeten</a>
  53. </form>
  54. <?php }
  55. else {
  56.  
  57.  
  58.  
  59. }
  60. ?>
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement