Advertisement
Guest User

Untitled

a guest
May 10th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. // Create connection to XAMPP and its DB
  6. $connection = mysqli_connect('localhost', 'root', '');
  7. if(!$connection)
  8. {
  9. die("Database connection failed".mysqli_error($connection));
  10. }
  11. $select_db = mysqli_select_db($connection, 'fleadbv2');
  12. if (!$select_db)
  13. {
  14. die("Database Selection Failed" . mysqli_error($connection));
  15. }
  16. // Get values passed from the html page
  17. $username = $_POST['loginusername'];
  18. $password = $_POST['loginpassword'];
  19. $login = "SELECT * FROM users WHERE username='$username' AND password='$password'";
  20.  
  21. session_start();
  22.  
  23. // Query the database
  24. $result = mysqli_query($connection, $login);
  25. // Places results in an array
  26. $row = mysqli_fetch_array($result);
  27. if ($row['username']==$username && $row['password']==$password)
  28. {
  29. echo "Welcome, ".$username;
  30. }
  31. else
  32. {
  33. echo "Login failed. Please check your credentials.";
  34. }
  35. ?>
  36.  
  37. Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\ProjectFlea\login.php on line 26
  38. Login failed. Please check your credentials.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement