Advertisement
Guest User

Login script

a guest
Dec 20th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?php
  2. $gebruikersnaam = "";
  3. $wachtwoord = "";
  4. $conn = new mysqli('host', 'username', 'password', 'database_name');
  5. if(mysqli_connect_errno()){
  6. trigger_error('Connection problem: '.$conn->error);
  7. }
  8.  
  9. if($_SERVER["REQUEST_METHOD"] === POST){
  10. $gebruikersnaam = $_POST['gebruiker'];
  11. $wachtwoord = $_POST['wachtwoord'];
  12.  
  13.  
  14. $sql = "SELECT * FROM users WHERE username = '$gebruikersnaam' and password = '$wachtwoord'";
  15. $result = mysqli_query($conn,$sql);
  16. $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  17. $count = mysqli_num_rows($result);
  18. if($count == 1) {
  19. echo "Hoi $gebruikersnaam";
  20. } else {
  21. echo "gebruikersnaam of wachtwoord is incorrect";
  22. }
  23. }
  24. }
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement