KangHoyong / F.T.2

University student for time task management system
1 stars 1 forks source link

Android App PHP Mysql Login and Register #1

Open KangHoyong opened 8 years ago

KangHoyong commented 8 years ago

There’s a lot of extra work........

  1. Login activity
  2. Register activity
  3. PHP linking and Mysql (ongoing) ~ server request class
  4. server communication (ongoing) ~ server request ~ packet Communication (authentication server) ~ packet Communication (Web server)
  5. android background service (ongoing)
  6. Login activity and Register activity UI fix !!!
KangHoyong commented 8 years ago

NameValuePair error 해결 방법 -> Map 사용

        ArrayList<NameValuePair> dataToSend = new ArrayList<>();
        dataToSend.add(new BasicNameValuePair("name", user.name));

        HttpParams httpRequestParams = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpRequestParams, CONNECTION_TIMEOUT);
        HttpConnectionParams.setSoTimeout(httpRequestParams, CONNECTION_TIMEOUT);

        HttpClient client = new DefaultHttpClient(httpRequestParams);
        HttpPost post = new HttpPost(SERVER_ADDRESS + "Register.php");

        try{
            post.setEntity(new UrlEncodedFormEntity(dataToSend));

        }catch (Exception e)
        {
            e.printStackTrace();
        }

수정 내용

        // Use HashMap, it works similar to NameValuePair
        Map<String, String> dataToSend = new HashMap<>();
        dataToSend.put("email", user.mail);
        dataToSend.put("password", user.password);
        dataToSend.put("name",user.name);
        dataToSend.put("phoneNumber", user.phoneNumber);
        dataToSend.put("birthData",user.birthDate);

        // 수정
        String encodedStr = getEncodedData(dataToSend);
        BufferedReader reader = null;

        // Connection Handling
        try {
            // Convertion address String to URL
            URL url = new URL(SERVER_ADDRESS + "Register.php");
            HttpURLConnection con = (HttpURLConnection) url.openConnection();

            // Post Method
            con.setRequestMethod("POST");
            // To enable inputting values using POST method
            con.setDoOutput(true);
            OutputStreamWriter writer = new OutputStreamWriter(con.getOutputStream());
            // Writing dataToSend to outputstream wirter
            writer.write(encodedStr);
            //Sending the data to the server - This much is enough to send data to server
            //But to read the response of the server, you will have to implement the procedure below
            writer.flush();

            //Data Read Procedure - Basically reading the data comming line by line
            StringBuilder sb = new StringBuilder();
            reader = new BufferedReader(new InputStreamReader(con.getInputStream()));

            String line;
            while ((line = reader.readLine()) !=null)
            {
                // Read till there is something available
                sb.append(line + "\n");
            }
            line = sb.toString();
            //Just check to the values received in Logcat
            Log.i("custom_check","The values received in the store part are as follows:");
            Log.i("custom_check",line);

        } catch (Exception e){
            e.printStackTrace();
        } finally {
            if(reader != null){
                try{
                    reader.close(); // Closing the
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
KangHoyong commented 8 years ago

OS MySQL mysql.server start mysql -h localhost -u root -p

show databases; 데이터 베이스 목록보기 use 데이터 베이스 이름 ; show tables;

KangHoyong commented 8 years ago

android register success ~~!!

2016-04-15 4 26 32
KangHoyong commented 8 years ago

Android App Icon & Splash Image size

2016-05-31 8 18 24