我只想阅读从 php Web 服务器回显的单行文本。但是我的代码会读取回显的文本以及网页源代码我只想删除源代码并只获取文本有没有办法单独获取文本
httpclient=new DefaultHttpClient();
httppost= new HttpPost("http://www.rock.bugs3.com/check.php");
nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(newBasicNameValuePair("username",
et.getText().toString().trim()));
$Edittext_value = $_POST['Edittext_value'];
nameValuePairs.add(newBasicNameValuePair("password",
pass.getText().toString().trim()));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
response=httpclient.execute(httppost);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
final String response = httpclient.execute(httppost, responseHandler);
System.out.println("Response : " + response);
runOnUiThread(new Runnable() {
public void run() {
tv.setText("Response from PHP : " + response);
dialog.dismiss();
我对 android 和 php 都是新手。这是我使用过的 php 代码
<?php
$hostname_localhost ="mysql.serversfree.com";
$database_localhost ="u154090_donor";
$username_localhost ="u154090_donor";
$password_localhost ="abcd";
$localhost = mysql_connect($hostname_localhost,$username_localhost,$password_localhost)
or
trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_localhost, $localhost);
$username = $_POST['username'];
$password = $_POST['password'];
$query_search = "select * from tbl_user where username = '".$username."' AND password = '".$password. "'";
$query_exec = mysql_query($query_search) or die(mysql_error());
$rows = mysql_num_rows($query_exec);
//echo $rows;
if($rows == 0) {
echo "No Such User Found";
}
else {
echo "User Found";
}
mysql_close($localhost);
?>`