valepunk Posted April 17, 2010 Share Posted April 17, 2010 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!!! Link to comment https://forums.phpfreaks.com/topic/198844-help-send-form-data-and-evaluate-the-xml-or-html-response/ Share on other sites More sharing options...
valepunk Posted April 23, 2010 Author Share Posted April 23, 2010 hi there finally I solved my code using curl and simplexml..... 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!!! Link to comment https://forums.phpfreaks.com/topic/198844-help-send-form-data-and-evaluate-the-xml-or-html-response/#findComment-1046889 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.