UrlEncodedFormEntity entity = new UrlEncodedFormEntity(
nameValuePairs, "UTF-8");
httppost.setEntity(entity);
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
String resultString = EntityUtils.toString(resEntity);
Log.e("testLog", "resultString : " + resultString.trim());
String str = resultString.trim();
if (str.equals("OK")) {
Intent intent = new Intent(Login.this, PatientActivity.class);
startActivity(intent);
finish();
} else {
Toast.makeText(this, str, Toast.LENGTH_LONG).show();
}
안드로이드 쪽이구욤
$query = " select user_id, pw, grade from pati_member A where user_id ='$user_id' and pw = '$pw' union select user_id, pw, grade from doc_member B where user_id = '$user_id' and pw = '$pw' ";
mysql_query("SET NAMES utf8");
$result = mysql_query($query,$connect);
$data = mysql_fetch_array($result);
//아무것도 입력하지 않고 로그인 버튼을 눌렀을 때
if(!$user_id)
{
echo"-1";
exit;
}
else if($data[user_id]!=$user_id)
{
echo"-2";
exit;
}
else if($data[pw]!=$pw)
{
echo"-3";
exit;
}
else
{
echo"OK";
exit;
}
mysql_close($connect);
setcookie("pl891029",$user_id,-1,"/");
?>
php 문이욤 .. 우선 값이 맞으면 OK이가 넘어오긴합니다. 하지만 if문을 통해서 intent되야 할텐데 그게 안됩니당 ㅠ 값이 틀리면 -2 -1이 넘어오기도 하구욤 ;;