【发布时间】:2015-09-08 01:43:48
【问题描述】:
我正在尝试为我的应用程序创建用户帐户并且我正在处理注册过程我在 AsynTask 扩展类中有以下代码:
HttpClient client = new DefaultHttpClient(httpRequestParams);
HttpPost post = new HttpPost(SERVER_ADDRESS + "Register.php");
ArrayList<NameValuePair> dataToSend = new ArrayList<>();
dataToSend.add(new BasicNameValuePair("name",user.name));
dataToSend.add(new BasicNameValuePair("username", user.username));
dataToSend.add(new BasicNameValuePair("password", user.password));
try {
post.setEntity(new UrlEncodedFormEntity(dataToSend));
}catch (UnsupportedEncodingException e){
e.printStackTrace();
}
try {
HttpResponse httpResponse = client.execute(post);
Log.d("ServerRequests", "client is executing");
Log.d("Http Post Response:",httpResponse.toString());
}catch (ProtocolException e){
e.printStackTrace();
}catch (IOException e){
e.printStackTrace();
}
在代码中使用上面的日志标记,我发现代码中的所有内容都被执行,除了以下行: HttpResponse httpResponse = client.execute(post); 这是我的php代码:
$name=$_POST["name"];
$username=$_POST["username"];
$password=$_POST["password"];
$statement=mysqli_prepare($con,"INSERT INTO users (name,username,password) VALUES (?,?,?)");
mysqli_stmt_bind_param($statement,"sss",$name,$username,$password);
mysqli_stmt_execute($statement);
mysqli_stmt_close($statement);
mysqli_close($con);
那么请您帮我找出这里的问题吗?
附加信息:我正在使用 wamp server v2.5 并且我正在向我的应用授予 Internet 权限
?>
【问题讨论】:
-
是
$_POST不是POST -
哦,谢谢你,真是个愚蠢的错误,但问题仍然没有解决。
标签: php android http registration