Advertisement
Guest User

login mysqli

a guest
Sep 16th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <?php
  2. require_once 'config.inc2.php';
  3.  
  4. $username = $_POST['username'];
  5. $password = $_POST['password'];
  6.  
  7. if (strlen($username) > 0 && strlen($password) > 0) {
  8.  
  9. $password = md5($password);
  10.  
  11. $stmt = $mysqli->prepare('SELECT username, password FROM users WHERE username = ? and password = ?');
  12. $stmt->bind_param("ss", $val1, $val2);
  13.  
  14. $val1 = $username;
  15. $val2 = md5($password);
  16.  
  17. $stmt->execute();
  18.  
  19. $stmt->bind_result($pizza);
  20. $stmt->fetch();
  21. var_dump($pizza);
  22. //var_dump($result);
  23.  
  24. var_dump($stmt->rowCount());
  25. if ($stmt->rowCount() === 1) {
  26. session_start();
  27.  
  28. $_SESSION['username'] = $username;
  29. header("location:home.php");
  30. } else {
  31. header("location:index.php");
  32. exit;
  33. }
  34. } else {
  35. echo "Niet alle velden zijn ingevuld!";
  36. exit;
  37. }
  38. $stmt->close();
  39. $pdo->close();
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement