I’m a total newbie at PHP, but this seems so simple, there doesn’t seem like any way for me to be screwing this up, unless I’m COMPLETELY misunderstanding the way all of this works.
Objective-C:
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://myurl.com"]];
[request setPostValue:@"test value A" forKey:@"testA"];
[request setPostValue:@"test value B" forKey:@"testB"];
[request setDelegate:self.delegate];
[request startAsynchronous];
PHP:
<?php
$testValueA = $_POST['testA'];
$testValueB = $_POST['testB'];
echo "Value A = $testValueA, Value B = $testValueB";
?>
When I NSLog the return string from the request, I get Value A = Value B = . Is this an error in my poorly understood PHP implementation, or is there an issue with the Objective-C?
–EDIT–
print_r($_POST), var_dump($_POST), and $HTTP_RAW_POST_DATA all return nothing. So I’m assuming that the problem lies in ASIFormDataRequest?
–EDIT 2–
Dumped the headers from the response:
Connection = "Keep-Alive";
"Content-Type" = "text/html";
Date = "Thu, 04 Nov 2010 20:05:39 GMT";
"Keep-Alive" = "timeout=2, max=199";
Server = Apache;
"Transfer-Encoding" = Identity;
"X-Powered-By" = "PHP/5.2.14";
Not sure what to do with this info.
–Edit 3–
Getting this log message from the error file:
"(Notice) Undefined index: testA"
Also one for testB
It appears that there was a redirect going on without my knowledge (From
http://www.mysite.comtohttp://www.mysite.com/), and was losing the POST data there. Thanks to everyone for trying to help debug this.