android <-> php <-> mysql 연동을 하려고 하고 있습니다. php내에서 mysql로 데이터가 넘어가는거는 확인이 되었는데 android에서 php로 데이터가 넘어가지 않고 있습니다.
밑에는 코드부분입니다.. ㄸㅏ로 오류메시지가 뜨는거는 없었습니다. 도와주세요
class Signup extends AsyncTask<String,Void,String>{
ProgressDialog progressDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = ProgressDialog.show(Sign.this,
"Please Wait", "회원가입중입니다.", true, true);
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
progressDialog.dismiss();
mTextViewResult.setText(result);
Toast toast = Toast.makeText(getApplicationContext(),"회원가입을 완료하셨습니다.",Toast.LENGTH_SHORT);
toast.show();
}
@Override
protected String doInBackground(String... params) {
String email = (String)params[0];
String pass = (String)params[1];
String name = (String)params[2];
String age = (String)params[3];
String sex = (String)params[4];
String serverURL = "http://210.119.146.209/PHP_signup.php";
String postParameters = "email=" + email + "&pass=" + pass + "&name=" +
name + "&age=" + age+ "&sex" + sex;
try{
URL url = new URL(serverURL);
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
//httpURLConnection.setReadTimeout(5000);
//httpURLConnection.setConnectTimeout(5000);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.connect();;
OutputStream outputStream = httpURLConnection.getOutputStream();
outputStream.write(postParameters.getBytes("UTF-8"));
outputStream.flush(); //현재 버퍼에 저장되어 있는 내용을 클라이언트로 전송하고 버퍼를 비운다.
outputStream.close();
int responseStatusCode = httpURLConnection.getResponseCode();
InputStream inputStream;
if(responseStatusCode == HttpURLConnection.HTTP_OK) {
inputStream = httpURLConnection.getInputStream();
}
else{
inputStream = httpURLConnection.getErrorStream();
}
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
StringBuilder sb = new StringBuilder();
String line = null;
while((line = bufferedReader.readLine()) != null){
sb.append(line);
}
bufferedReader.close();
return sb.toString();
}catch (Exception e){
return new String("Error:"+e.getMessage());
}
}
}