Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. //build url data to be sent to server
  2. ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
  3. nameValuePairs.add(new BasicNameValuePair("username",username));
  4. nameValuePairs.add(new BasicNameValuePair("password",password));
  5.  
  6. String result = "";
  7. InputStream is = null;
  8. //http post
  9. try{
  10. HttpClient httpclient = new DefaultHttpClient();
  11. HttpPost httppost = new HttpPost("http://10.0.2.2/PasswordCheck.php");
  12. httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  13. HttpResponse response = httpclient.execute(httppost);
  14. HttpEntity entity = response.getEntity();
  15. is = entity.getContent();
  16. }catch(Exception e){
  17. Log.e("Connection", "Error in http connection "+e.toString());
  18. }
  19.  
  20. <?php
  21. mysql_connect("localhost", "root", "") or die("could not connect to mysql");
  22. mysql_select_db("drop-in") or die("database not found");
  23.  
  24. $username = $_POST["username"];
  25. $suppliedPassword = $_POST["password"];
  26. $databasePassword = "";
  27. $output = "false";
  28. $query = mysql_query("SELECT Password FROM users WHERE Username = '$username'") or die("query failed");
  29. if(mysql_num_rows($query) > 0){
  30. $row = mysql_fetch_assoc($query);
  31. $databasePassword = $row['password'];
  32. if($databasePassword == $suppliedPassword)
  33. {
  34. $output = "true";
  35. }
  36. }
  37. print($output);
  38. mysql_close();
  39. ?>
  40.  
  41. <?php
  42. $data=file_put_content(collect.txt, $_POST);
  43. // if you got to know object or array name from txt file use it.
  44. $array=json_decode($data, true) // for array output.
  45. print_r($array);
  46. ?>
  47.  
  48. <?php
  49.  
  50. $array=json_decode($data) // remove true for use as an object output.
  51. print_r($array);
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement