Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //build url data to be sent to server
- ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
- nameValuePairs.add(new BasicNameValuePair("username",username));
- nameValuePairs.add(new BasicNameValuePair("password",password));
- String result = "";
- InputStream is = null;
- //http post
- try{
- HttpClient httpclient = new DefaultHttpClient();
- HttpPost httppost = new HttpPost("http://10.0.2.2/PasswordCheck.php");
- httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
- HttpResponse response = httpclient.execute(httppost);
- HttpEntity entity = response.getEntity();
- is = entity.getContent();
- }catch(Exception e){
- Log.e("Connection", "Error in http connection "+e.toString());
- }
- <?php
- mysql_connect("localhost", "root", "") or die("could not connect to mysql");
- mysql_select_db("drop-in") or die("database not found");
- $username = $_POST["username"];
- $suppliedPassword = $_POST["password"];
- $databasePassword = "";
- $output = "false";
- $query = mysql_query("SELECT Password FROM users WHERE Username = '$username'") or die("query failed");
- if(mysql_num_rows($query) > 0){
- $row = mysql_fetch_assoc($query);
- $databasePassword = $row['password'];
- if($databasePassword == $suppliedPassword)
- {
- $output = "true";
- }
- }
- print($output);
- mysql_close();
- ?>
- <?php
- $data=file_put_content(collect.txt, $_POST);
- // if you got to know object or array name from txt file use it.
- $array=json_decode($data, true) // for array output.
- print_r($array);
- ?>
- <?php
- $array=json_decode($data) // remove true for use as an object output.
- print_r($array);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement