Guest User

Untitled

a guest
Aug 5th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. $username = trim($_POST['username']);
  2. $password = trim($_POST['password']);
  3.  
  4. if (isset($username) AND isset($password)) {
  5. $db = new DBOperations();
  6.  
  7. if($db->userLogin($username, $password)) {
  8. $user = $db->getUsernameByUsername($username);
  9. $response['error'] = false;
  10. $response['message'] = "succes";
  11. }else {
  12. $response['error'] = true;
  13. $response['message'] = "Invalid username or password";
  14. }
  15. }else {
  16. $response['error'] = true;
  17. $response['message'] = "Required fields are missing";
  18. }
  19.  
  20. public function userLogin($username, $pass) {
  21. $stmt = $this->conn->prepare("SELECT id FROM students WHERE s_id = ?");
  22. $stmt->bind_param("s", $username);
  23. $stmt->execute();
  24. $stmt_result = $stmt->get_result();
  25. if($stmt_result = $stmt->num_rows > 0) {
  26. while($row_data = $stmt_result->fetch_assoc(MYSQLI_ASSOC)) {
  27. # Action to do
  28. echo "success";
  29. }
  30.  
  31. } else {
  32. # No data actions
  33. echo 'No data here :(<br/>';
  34. }
  35. }
Add Comment
Please, Sign In to add comment