학교 웹사이트를 학번과 비밀번호로 로그인 해서 정보를 받아오려고 가상으로 서버를 만들어서 테스트 중인데요
컴퓨터로 log_find.php로 연결 했을땐 1이 라는 값을 출력 합니다.
안드로이드로 했을땐 실행은 오류 없이 잘 되는데 이게 phpmyadmin 에서 로그를 보면
접속 한 흔적이 없습니다. 어디에 문제가 있나요?
아파치로 서버 돌리고 있습니다.
AndroidManifest.xml
추가-> <uses-permission android:name="android.permission.INTERNET"></uses-permission>
log_find.php
<?php
include"./p_dbconn.php.inc";
$std_id = $_POST["id"];
$std_pw = $_POST["pw"];
$sql="select * from $tbl_name where std_id='$std_id' and std_pw='$std_pw'";
$result=mysql_query($sql,$connect);
$list=mysql_num_rows($result);
//echo $list;
?>
<?
mysql_query("set names utf8");
echo '<?xml version="1.0" encoding="utf-8" ?>';
?>
<xml>
<?php
echo '<item login ="'.$list.'"/>';
?>
</xml>
안드로이드
package KST.Test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import android.app.Activity;
import android.os.Bundle;
public class Main extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
InputStream is = null;
String totalMessage = "";
String url = "http://203.250.143.54/log_find.php";
HttpClient httpclient = new DefaultHttpClient();
try {
/** 연결 타입아웃내에 연결되는지 테스트, 5초 이내에 되지 않는다면 에러 */
String id = "0761001";
String pw = "55";
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("id", id));
nameValuePairs.add(new BasicNameValuePair("pw", pw));
/** 네트웍 연결해서 데이타 받아오기 */
String result = "";
HttpParams params = httpclient.getParams();
HttpConnectionParams.setConnectionTimeout(params, 5000);
HttpConnectionParams.setSoTimeout(params, 5000);
HttpPost httppost = new HttpPost(url);
UrlEncodedFormEntity entityRequest =
new UrlEncodedFormEntity(nameValuePairs, "UTF-8");
httppost.setEntity(entityRequest);
HttpResponse response = httpclient.execute(httppost);
HttpEntity entityResponse = response.getEntity();
is = entityResponse.getContent();
/** convert response to string */
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
is.close();
result = sb.toString();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
} finally {
httpclient.getConnectionManager().shutdown();
}
};
}
음... httpclient는 잘 사용하지 않는 라이브러리라 잘 몰라서 답변드리기가 힘드네요..
전 주로 웹 관련 연결을 할 때 UrlConnection, HTTPUrlConnection 을 사용하는데 이들을 한번 사용해보시는건 어떤가요?
접속한 흔적이 없다는건 무슨뜻인가요? 서버에서 돌아가는 php가 남긴 흔적이라는 뜻인가요
아니면 아파치 access로그기록이 없다는 뜻인가요?
아파치 접속로그가 없다는건 조금 이상하네요