Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "mysql-xxnorxx.alwaysdata.net";
  4. $username = "xxnorxx";
  5. $password = "*****";
  6. $dbName = "xxnorxx_testdb";
  7.  
  8. $user_username = $_POST["usernamePost"];
  9. $user_password = $_POST["passwordPost"];
  10.  
  11. $conn = new mysqli($servername, $username, $password, $dbName);
  12.  
  13. if (!$conn) {
  14. echo ("Not connected to server");
  15. }
  16.  
  17. $loginSQL = "SELECT * FROM users WHERE username = '$user_username'";
  18. $loginQuery = mysqli_query ($conn, $loginSQL);
  19.  
  20. if (mysqli_num_rows ($loginQuery) > 0) {
  21. echo ("User found");
  22. while ($row = mysqli_fetch_assoc($result)) {
  23. if ($row['password'] == $user_password) {
  24. echo ("Login success");
  25. } else {
  26. echo ("Incorrect password");
  27. }
  28. }
  29. } else {
  30. echo ("No user was found");
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement