0

I'm trying to create user accounts for my applicatin and i'm working on the register process i have the following code in an AsynTask extended class:

        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();
        }

useing the log Tag above in the code i figured out that everything in the code is executed except for the line: HttpResponse httpResponse = client.execute(post); here is my php code:

$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);

so would you please help me identify the problem here?

additional information: i'm using wamp server v2.5 and i'm granting Internet permission to my app

?>

RiggsFolly
  • 89,708
  • 20
  • 100
  • 143
T.souri
  • 41
  • 7

1 Answers1

0

HttpClient is deprecated in maybe SDK v20, and clear is that it is not available in SDK v23, you should use HttpURLConnection, see this link

How to add parameters to HttpURLConnection using POST

Community
  • 1
  • 1
  • i thought it is deprecated from SDK v22 so i changed the SDK version to 22 thought it would work fine, i will check out HttpURLConnection, Thank you. – T.souri Sep 08 '15 at 03:28