Pasar como parametro el valor de un input a una funcion
Publicado por Sergio Alzamora (1 intervención) el 24/09/2023 00:00:20
Estimados buenas tardes, en la siguiente funcion como puedo pasar el valor de un input a la variable $id y llamarla desde un button, agradezco su apoyo
function buscarID($id)
{
$curl = curl_init();
curl_setopt_array(
$curl,
array(
CURLOPT_URL => 'https://api.org/id?numero=' + $id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer xxxxxxxx'
),
)
);
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
$id = $_POST["id_cliente"]; //aqui debe ir el valor ingrsado en un input
$response = buscarID($id);
function buscarID($id)
{
$curl = curl_init();
curl_setopt_array(
$curl,
array(
CURLOPT_URL => 'https://api.org/id?numero=' + $id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer xxxxxxxx'
),
)
);
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
$id = $_POST["id_cliente"]; //aqui debe ir el valor ingrsado en un input
$response = buscarID($id);
Valora esta pregunta


0