2

I have an android app and am trying to send data to the PHP on the server. The server gets the php data with

$this->get('uname');
$this->get('pass');

We do use codeigniter if that matters

The Java code, inside of an Async method, I currently have is

InputStream response = null;
URLConnection connection = new URL(urls[0]).openConnection();
connection.setRequestProperty("uname" , Username);
connection.setRequestProperty("pass", Password);
response = connection.getInputStream();

When I run this, the code always returns null but it is supposed to return a JSON array either way. I have checked the URL and it is correct. What am I doing wrong? Thanks!

Zach Babbitt
  • 127
  • 1
  • 7

1 Answers1

1

You code should be like this For your android side ,as mentioned by @Ichigo Kurosaki at Sending POST data in Android

For Codeigniter side , cosider you function name is user_login

function user_login(){
$uname = $this->input->get_post('uname'); //get_post will work for both type of GET/POST request
$pass =  $this->input->get_post('pass');
$result=$this->authenticate->actLogin($uname,$pass  ); //considering your authenticating user and returning 1,0 array as success/failure
$this->output
    ->set_content_type('application/json')
    ->set_output(json_encode($result));
exit;
}
Community
  • 1
  • 1
Sanjay Sinalkar
  • 488
  • 2
  • 8