php - Sending POST Request to Local Host, Data Being Received But Not Showing Up On Webpage -



php - Sending POST Request to Local Host, Data Being Received But Not Showing Up On Webpage -

i've been @ lastly couple of days. i'm sending info iphone app localhost on mamp. info beingness sent , beingness received server, because response i'm getting php code running on webpage, isn't showing on webpage. there way create webpage display token beingness received? sense problem basic php script. thanks. here's code:

objective-c:

nsmutableurlrequest *request = [[nsmutableurlrequest alloc] initwithurl:[nsurl urlwithstring:@"http://192.168.2.12:8888/hello_world.php"]]; request.httpmethod = @"post"; nsstring *body = [nsstring stringwithformat:@"stripetoken=%@", token.tokenid]; nslog(body); request.httpbody = [body datausingencoding:nsutf8stringencoding]; nsurlresponse *response; nserror *error; nsdata *data = [nsurlconnection sendsynchronousrequest:request returningresponse:&response error:&error]; nslog([[nsstring alloc] initwithdata:data encoding:nsutf8stringencoding]);

php:

<?php echo "hello, world!"; print_r($_post); ?>

nslog:

2014-06-18 12:40:12.300 payphone prototype[3775:60b] received token tok_104f7r4h7nunb2nuo3xohpyk 2014-06-18 12:40:12.301 payphone prototype[3775:60b] stripetoken=tok_104f7r4h7nunb2nuo3xohpyk 2014-06-18 12:40:12.306 payphone prototype[3775:60b] <html> <head> <title>php test</title> </head> <body> hello, world!array ( [stripetoken] => tok_104f7r4h7nunb2nuo3xohpyk ) </body> </html>

webpage:

hello, world!array ( )

the reason why webpage showing "wrong" content because browser send request when visit url writing url in address bar.

replace php this:

<?php echo "hello, world!"; if ($_server['request_method'] == 'post') { print_r($_post); } else { echo "this not post"; } ?>

and see it.

in order have browser send post, should, e.g., create form post php page; or in javascript (similarly doing objective-c). uncertainty useful.

so, seems app working , php page behaving correctly.

possibly should explain trying loading php page in browser -- if testing, not need it. nslog added tells all.

php ios post

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -