我现在要做一个实现注册功能的APP,卡在如何按下按钮之后php能接收到app输入的账号密码信息。然后访问数据库,验证账号是否存在。如果存在返回“账号已存在”。如果不存在。则写入数据库。
我知道要用get或者psot来写。但是php那边的不太会 。
app方面的代码如下。请大神看一下有没有问题。 另外教一下php应该怎么写。感谢感谢!
package com.wbb.hart.server;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
/**
* Created by think on 2015/8/12.
*/
public class HttpThread extends Thread {
String url;
String name;
String pwd;
public HttpThread(String url,String name,String pwd){
this.url = url;
this.name = name;
this.pwd = pwd;
}
private void doGet(){
url = url + "?name = " +name + "&pwd = " + pwd ;
try {
URL httpUrl = new URL(url);
try {
HttpURLConnection conn =(HttpURLConnection) httpUrl.openConnection();
conn.setRequestMethod("GET");
conn.setReadTimeout(5000);
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String str;
StringBuffer sb = new StringBuffer();
while((str = reader.readLine())!=null){
sb.append(str);
}
System.out.println("Result:" + sb.toString());
} catch (IOException e) {
e.printStackTrace();
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
public void run(){
doGet();
}
}
关于淡淡的淡淡的
关于淡淡的淡淡的
晚安sp