Receive an object as parameter in PHP controller

1

I am working with a mobile api which sends this data by POST :

@Injectable()
export class UsuarioProvider {

  datos: any;
  api: string = 'http://10.5.10.230/TaxisPlu/moviles/app_cliente/registrar_usuario/';

  constructor(public http: Http) {
    console.log('Hello UsuarioProvider Provider');
  }

  crear_usuario(datos) {
    let body = datos;
    let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' });
    headers.append("Accept", 'application/json');
    return this.http.post(this.api, body, {
      headers: headers,
      method: "POST"
    }).map(
      (res: Response) => { return res.json(); }
      );
  }

}

And it is received by a controller

public function registrar_usuario() {
       ///COMO LEER ESA INFORMACION
    }

My question is how to read the Form Data in my PHP. Thanks

    
asked by Ivan More Flores 27.10.2017 в 17:14
source

1 answer

1

If you send it through POST, in your function you can read those values using the input class of codeigniter, in code it would be something like this:

public function registrar_usuario() {
  ///COMO LEER ESA INFORMACION
  $name  = $this->input->post("name");
  $lastname  = $this->input->post("lastName");
  //Y así con los demas campos.
}
    
answered by 27.10.2017 в 17:23