Guest User

Untitled

a guest
Jul 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $host="bakkerijdeclercq.be.mysql"; // Host name
  4. $Gebruikersnaam="Gebruikersnaam"; // Mysql username
  5. $Wachtwoord="Wachtwoord"; // Mysql password
  6. $db_name="bakkerijdeclerc"; // Database name
  7. $tbl_name="Gegevens"; // Table name
  8.  
  9.  
  10. // Connect to server and select databse.
  11. mysql_connect( "bakkerijdeclercq.be.mysql", "bakkerijdeclerc", "pssword") or die ('ERROR: ' .mysql_error());
  12. mysql_select_db( "bakkerijdeclerc" );
  13.  
  14. // username and password sent from form
  15. $Gebruikersnaam=$_POST['Gebruikersnaam'];
  16. $Wachtwoord=$_POST['Wachtwoord'];
  17.  
  18. // To protect MySQL injection
  19. $Gebruikersnaam = stripslashes($Gebruikersnaam);
  20. $Wachtwoord = stripslashes($Wachtwoord);
  21. $Gebruikersnaam = mysql_real_escape_string($Gebruikersnaam);
  22. $Wachtwoord = mysql_real_escape_string($Wachtwoord);
  23.  
  24. $sql="SELECT * FROM $tbl_name WHERE Gebruikersnaam='$Gebruikersnaam' and Wachtwoord='$Wachtwoord'";
  25. $result=mysql_query($sql);
  26.  
  27. // Mysql_num_row is counting table row
  28. $count=mysql_num_rows($result);
  29.  
  30. // If result matched $Gebruikersnaam and $Wachtwoord, table row must be 1 row
  31. if($count==1){
  32. // Register $Gebruikersnaam, $Wachtwoord and redirect to file "login_succes.php"
  33. $_SESSION['logedin'] = true;
  34. $_SESSION['username'] = $Gebruikersnaam;
  35. header("location:gelukt.php");
  36. }
  37. else {
  38. header("location:niet_gelukt.php");
  39. }
  40.  
  41. ob_end_flush();
  42. ?>
Add Comment
Please, Sign In to add comment