我創建通過以下POST方法客觀-CPOST方法
-(IBAction) postLocation: (id) sender{
NSString *latitude = @"37.3229978";
NSString *longitude = @"-122.0321823";
NSMutableURLRequest *request =[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.mydomain.me/webservice.php"]];
[request setHTTPMethod:@"POST"];
NSString *post =[[NSString alloc] initWithFormat:@"latitude=%@longitude=%@submit",latitude,longitude];
[request setHTTPBody:[post dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response;
NSError *err;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
}
和我的PHP代碼:
if (isset($_POST['submit']){
//it doesn't get into this if statement
$latitude = $_POST['latitude'];
$longitude = $_POST['longitude'];
}
的問題是,爲什麼不能PHP代碼進入if語句?我在哪裏可以通過Objective-C來陳述'提交'?
你有沒有找到答案?我有這個確切的問題:http://stackoverflow.com/questions/13110180/php-get-value-erased-when-placed-in-ifisset – Celeste 2012-10-29 10:08:43