So, i'm trying to send message via Post in Android to PHP here is the Android Java Function:
//enviando para o backend
private void SendtoPHP(String reg) throws IOException {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://bubbledev.com.br/gcm/getdevice.php");
try{
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("regid", "" + reg ));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
}
catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
The PHP:
<?php
include 'conecta.php';
$device_token = urldecode($_POST['regid']);
$sql = "INSERT INTO corposa.deviceandroid"
. " (id,device_token)"
. " VALUES (NULL,'$device_token')";
mysqli_query($con,$sql);
?>
The PHP is Just fine, I already tested it with a another Post and worked, but when the Android function tries $device_token dont recive any value and the SQL save a "" with the id at the table