Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2.  
  3. include 'includes/db.php';
  4.  
  5. // Check whether username or password is set from android
  6. if(isset($_POST['username']) && isset($_POST['password']))
  7. {
  8. // Innitialize Variable
  9. $result='';
  10. $username = $_POST['username'];
  11. $password = $_POST['password'];
  12.  
  13. //$username = 'selva';
  14. //$password = 'password';
  15.  
  16. // Query database for row exist or not
  17. $sql = 'SELECT userid,fullname,rn FROM users WHERE username = :username AND password = :password';
  18. $stmt = $conn->prepare($sql);
  19. $stmt->bindParam(':username', $username, PDO::PARAM_STR);
  20. $stmt->bindParam(':password', $password, PDO::PARAM_STR);
  21. $stmt->execute();
  22. if($stmt->rowCount())
  23. {
  24. while ($row = $stmt->fetch(PDO::FETCH_ASSOC))
  25. {
  26. $result=['status'=>'true','userid'=>$row['userid'],'fullname'=>$row['fullname'],'rn'=>$row['rn']];
  27. }
  28. }
  29. elseif(!$stmt->rowCount())
  30. {
  31. $result=['status'=>'false'];
  32. }
  33. // send result back to android
  34. echo json_encode($result);
  35. }
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement