I'm doing a registry of users in android (confirm that if you send the necessary values) but when you get to the php my variable $ user and $ pass become null even though in the mysql table if you insert the record but blank data.
Use Restlet client to emulate the operation of my php code (which I do not know why it does not work)
also sometimes sent data to my php code: link
the answer in both cases is this: successful connection (php connection file) Username and password equals null (input values).
<?php
require_once("conexion.php");
$data = empty($_POST) ? json_decode(file_get_contents('php://input'),
true) : $_POST;
$usuario = $data["usuario"];
$pass = $data["contrasena"];
$respuesta = array(
"resultado"=> false,
"mensaje" => ""
);
if($usuario==null&&$pass==null){
echo "Usuario y contraseña es igual a null";
}
else{
$sql_insert="insert into usuarios VALUES (null,'$usuario','$pass')";
$result=mysqli_query($conexion,$sql_insert);
if($result){
$respuesta["resultado"]=true;
$respuesta["mensaje"]="Se guardo la información";
}else{
$respuesta["mensaje"]="Error";
}
echo json_encode($respuesta);
}
?>
add an if to validate that $ user and $ pass are not empty since it inserts but carries them with null values.
I hope you can help me, thank you.