안녕하세요 조금씩 만들면서 공부중인 사람입니다.
안드로이드 php mysql 로 로그인을 구현중인데요;
id 중복확인에서 자꾸 " 중복된 id "라고만 나오네요 모든 입력 값들이요..
전체적으로 한번 봐주시길 바랍니다. 전체 소스는 아니구요. id 중복확인 쪽 코드만 넣었습니다.
------------------------------------php-------------------------------------
<?php
session_start();
include('phpConnect.php');
$id = $_POST['ID'];
$r = mysql_query("select ID from User_Info where ID='$id'", $con);
$row = mysql_fetch_row($r);
$create = "0";
$failed = "1";
if($r == "0")
{
print(json_encode($create));
}
else
{
print(json_encode($failed));
}
?>
-----------------------------------------android A activiy ----------------------------
public class controlMysql extends Thread {
public static boolean active = false;
Handler mHandler = new Handler();
String url = null;
int gettype = 0;
public controlMysql(String id)
{
String chk_url = "";
mHandler = new Handler();
String userId = id;
url = chk_url + userId;
gettype = 1;
}
public controlMysql(String id, String name, String age, String phone, String mail, String address, String pw)
{
String insert_url = "";
String userId = id;
String userName = name;
String userAge = age;
String userPhone = phone;
String userMail = mail;
String userAddress = address;
String userPw = pw;
url = insert_url+userId+userName+userAge+userPhone+userMail+userAddress+userPw;
gettype = 2;
}
@Override
public void run()
{
super.run();
if(active)
{
StringBuilder jsonHtml = new StringBuilder();
try
{
URL phpUrl = new URL(url);
HttpURLConnection con = (HttpURLConnection)phpUrl.openConnection();
if(con != null)
{
con.setConnectTimeout(10000);
con.setUseCaches(false);
if(con.getResponseCode() == HttpURLConnection.HTTP_OK)
{
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
while(true)
{
String line = br.readLine();
if(line == null)
break;
jsonHtml.append(line+"\n");
br.close();
}
con.disconnect();
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
show(jsonHtml.toString());
}
}
void show(final String result)
{
mHandler.post(new Runnable()
{
@Override
public void run()
{
switch(gettype)
{
case 1:
ChkId.chkidResult(result);
break;
case 2:
Login.regist_result(result);
break;
}
}
});
}
}
------------------------------------ android B activity --------------------------------
static public void chkidResult(String result)
{
if(result.equals("0"))
{
description.setText("사용이 가능합니다.");
chkok=true;
}
else
{
description.setText("중복된 ID 입니다.");
chkok = false;
}
}
여기서 description.setText("중복된 ID 입니다."); 만 실행이 되버리네요;;
잘못된 점 바로잡아주시길 바랍니다.