how is server receive request

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hero132
Forum Newbie
Posts: 5
Joined: Mon Oct 19, 2009 4:04 am

how is server receive request

Post by hero132 »

Hello all,
I writing a website, it has a function that it will receive request from a application program. When the program sent request to
it, it will receive request and parser request content then sent again response to the program. But I don't know website will listen request and receive request. Can you help me?
I trying to use $_POST in website to listen and receive request from the program but no success.
My code:
foreach ($_POST as $key => $value)
{
echo "$_POST";
}
Thanks,
User avatar
el_gato
Forum Newbie
Posts: 12
Joined: Sun Oct 18, 2009 9:28 pm
Location: Bandung
Contact:

Re: how is server receive request

Post by el_gato »

hero132 wrote:Hello all,
I writing a website, it has a function that it will receive request from a application program. When the program sent request to
it, it will receive request and parser request content then sent again response to the program. But I don't know website will listen request and receive request. Can you help me?
I trying to use $_POST in website to listen and receive request from the program but no success.
My code:
foreach ($_POST as $key => $value)
{
echo "$_POST";
}
Thanks,
echo $_POST will result an array, not the parameters and values sent by your application program. From your code above, the value is $value and the parameter is $key. if $_POST was empty, try to use $_GET.

Kind Regards
- Lorensius W. L. T
- http://www.londatiga.net-
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: how is server receive request

Post by califdon »

hero132 wrote:Hello all,
I writing a website, it has a function that it will receive request from a application program. When the program sent request to
it, it will receive request and parser request content then sent again response to the program. But I don't know website will listen request and receive request. Can you help me?
I trying to use $_POST in website to listen and receive request from the program but no success.
My code:
foreach ($_POST as $key => $value)
{
echo "$_POST";
}
Thanks,
It sounds like you are describing an Ajax transaction. If your application is not sending an entire web page ("<html> ..."), but only sending data, then the page that requests the data must include a call to the XMLHttpRequest object, including a function to receive the data when the ReadyState indicates that new data has been received. Read http://www.w3schools.com/Ajax/ajax_httprequest.asp.
hero132
Forum Newbie
Posts: 5
Joined: Mon Oct 19, 2009 4:04 am

Re: how is server receive request

Post by hero132 »

Thanks everybody
I sent data from application program that i write by actionscript, it will sent request which is a text file to my webserver,
Code of it is :
var request:URLRequest = new URLRequest( "http://wcc.dyndns.org/ppListen/pp-lis.php" );

// Create some variables to send
var user:String = "admin";
var pass:String = "123456";
var variables:URLVariables = new URLVariables();
variables.someText = "user_active:" + user + ", pass_active:" + pass;
request.data = variables;
sendToURL(request);
request.method = URLRequestMethod.POST;

After I want my webserver will receive text file and parser it to response to application software. Above, I only echo "$_POST" to test webserver received request content, but it show nothing
I can't how i should process it to receive the request.
User avatar
el_gato
Forum Newbie
Posts: 12
Joined: Sun Oct 18, 2009 9:28 pm
Location: Bandung
Contact:

Re: how is server receive request

Post by el_gato »

try using var_dump($_REQUEST), see the results..
hero132
Forum Newbie
Posts: 5
Joined: Mon Oct 19, 2009 4:04 am

Re: how is server receive request

Post by hero132 »

I used your way but not success, I still can't get content of request from application software
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: how is server receive request

Post by Mark Baker »

Do the web server logs show that it has received the request?
User avatar
el_gato
Forum Newbie
Posts: 12
Joined: Sun Oct 18, 2009 9:28 pm
Location: Bandung
Contact:

Re: how is server receive request

Post by el_gato »

hero132 wrote:I used your way but not success, I still can't get content of request from application software
Check your web server access log..

Kind Regards
-Lorensius W. L. T-
-http://www.londatiga.net-
hero132
Forum Newbie
Posts: 5
Joined: Mon Oct 19, 2009 4:04 am

Re: how is server receive request

Post by hero132 »

Thank you so much
I received content of request. Do you help me, how can i sent response to application software?
You guide me about sent response to application software.
User avatar
el_gato
Forum Newbie
Posts: 12
Joined: Sun Oct 18, 2009 9:28 pm
Location: Bandung
Contact:

Re: how is server receive request

Post by el_gato »

To send response back to your application just print any string that what your application need.
Ex,

if ($_POST['test']) {
...
..
..
die('OK');
}

Kind Regards
- Lorensius W. L. T -
- http://www.londatiga.net -
hero132
Forum Newbie
Posts: 5
Joined: Mon Oct 19, 2009 4:04 am

Re: how is server receive request

Post by hero132 »

I done
Thank you so much
Post Reply