Jump to content

HELP!! send form data and evaluate the xml or html response


valepunk

Recommended Posts

Hi everybody, Im learning PHP code and I cant figure out how to contruct an aplication for the next exercise: I have a html form that calls to a php file, this php file send a http request (http://www.example.com/receive?name=xxxx&address=xxxx) once that the server receptor catch this request returns with XML or HTML a OK or a KO.

I had read about curl, xml parser and other options but to be honest I dont know if this is the correct way, Im posting a piece of the code that contains my php file.

 

if (condition){  

$url = 'http://www.example.com/app';

$body = $urlnext;

echo $body;

$c = curl_init($url);

curl_setopt($c, CURLOPT_POST, true);

//curl_setopt($c, CURLOPT_POSTFIELDS, $body);

curl_setopt($c, CURLOPT_POSTFIELDS, $body);

curl_setopt($c, CURLOPT_RETURNTRANSFER, true);

$page = curl_exec($c);

curl_close($c);

echo $page;  <<< this is the answear to be evaluate shuld be evaluate

 

 

I hope somebody can help me to get a correct way to contruct this exercise any idea is welcome

thanks in advice and good vibes!!!

hi there finally I solved my code  using curl and simplexml.....  :D here is an example

 

                                                        $movil = $_POST['movil'];

$codp = $_POST['codp'];

$url = 'http://www.example.com/example';

$body = 'movil='. $movil .'&codp='.$codp;

$options = array('method' => 'POST', 'content' => $body);

$context = stream_context_create(array('http' => $options));

$page = file_get_contents($url, false, $context);

$respuesta=new SimpleXMLElement($page);

$ganador = $respuesta->ganador;

$mensaje =$respuesta->mensaje;

$premio =$respuesta->premio;

 

I hope helps to anybody

 

vibres!!

 

Hi everybody, Im learning PHP code and I cant figure out how to contruct an aplication for the next exercise: I have a html form that calls to a php file, this php file send a http request (http://www.example.com/receive?name=xxxx&address=xxxx) once that the server receptor catch this request returns with XML or HTML a OK or a KO.

I had read about curl, xml parser and other options but to be honest I dont know if this is the correct way, Im posting a piece of the code that contains my php file.

 

if (condition){  

$url = 'http://www.example.com/app';

$body = $urlnext;

echo $body;

$c = curl_init($url);

curl_setopt($c, CURLOPT_POST, true);

//curl_setopt($c, CURLOPT_POSTFIELDS, $body);

curl_setopt($c, CURLOPT_POSTFIELDS, $body);

curl_setopt($c, CURLOPT_RETURNTRANSFER, true);

$page = curl_exec($c);

curl_close($c);

echo $page;  <<< this is the answear to be evaluate shuld be evaluate

 

 

I hope somebody can help me to get a correct way to contruct this exercise any idea is welcome

thanks in advice and good vibes!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.