Reputation: 2140
I need to access POST for PHP from my iOS application. I can't seem to get it to work though.
Here is a very short snippet of the PHP:
$post_data = $_POST["function"];
if ($function == 'post_data') {
//do stuff, not important
else if($function == 'send_stuffz') {
//do stuff, not important
}
How do I access this portion of the code?
I thought it could just be through a URL such as:
fakewebsitename.com/file.php?function=post_data
fakewebsitename.com/file.php?function=send_stuffz
But that doesn't work.
In the iOS app, I have this thus far:
NSMutableURLRequest *urlReq = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:baseURL]]; <-baseURL = fakewebsitename.com/file.php in this "instance"
[urlReq setHTTPMethod:@"POST"];
Not sure how to proceed...
Upvotes: 0
Views: 123
Reputation: 23480
this function is incorrect
$post_data = $_POST["function"];
if ($function == 'post_data') {
//do stuff, not important
else if($function == 'send_stuffz') {
//do stuff, not important
}
you are not defining variable $function
please change as follow
please change to
$post_data = $_POST["function"];
if ($post_data == 'post_data') {
//do stuff, not important
else if($post_data == 'send_stuffz') {
//do stuff, not important
}
Upvotes: 2