Advertisement
Guest User

Login API

a guest
Sep 9th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <?php
  2. $con = mysqli_connect("mysql12.000webhost.com", "a5340628_user", "118sandy118", "a5340628_data");
  3.  
  4.  
  5. $username = $_POST["username"];
  6. $password = $_POST["password"];
  7.  
  8. $statement = mysqli_prepare($con, "SELECT * FROM user WHERE username = ? AND password = ?");
  9. mysqli_stmt_bind_param($statement, "ss", $username, $password);
  10. mysqli_stmt_execute($statement);
  11.  
  12. mysqli_stmt_store_result($statement);
  13. mysqli_stmt_bind_result($statement, $userID, $name, $username, $age, $password);
  14.  
  15. $response = array();
  16. $response["success"] = false;
  17.  
  18. while(mysqli_stmt_fetch($statement)){
  19. $response["success"] = true;
  20. $response["name"] = $name;
  21. $response["age"] = $age;
  22. $response["username"] = $username;
  23. $response["password"] = $password;
  24. }
  25.  
  26. echo json_encode($response);
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement