Page 1 of 1

post method example

Posted: Thu Mar 27, 2008 8:35 am
by ltcabral
Hello,
im learning about post method and im having some problemas... could anyone post here a simple php code that would receive an specific post and return a XML file? (the part that send the post is done, i did it in C, but not the part to receive) its enough for me to understand how to use it in other ways (the tutorials i read didnt help enough...)
thx

Re: post method example

Posted: Thu Mar 27, 2008 9:05 am
by timvw
The following code would accept posted xml data and save it in $data:

Code: Select all

 
$data = file_get_contents(‘php://input’);
 

Re: post method example

Posted: Thu Mar 27, 2008 9:12 am
by ltcabral
hm... actually i will send a string, and i want it to return the xml...

the post i must send is something like

"$POST[in_chktest] => xxx"
and i want it to check it and return diferent XML according to xxx

im using C funcions from libcurl library which will automaticaly get the result
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "$POST[in_chktest] => test");
result = curl_easy_perform(curl);