how insert data to remote database from ip+phone Application
I am accessing a php website in my iphone application.
i want that user read the blogs in their iphone application and when they comments on any blog the开发者_如何学Pythonir comment are stored in the website database.
any idea how to do this.
OR what i need to study to Talk with remote database.....
Thanks In advance.
When user read the blogs and when he give comment on that blog u simply post that comment to a php page which save it on the server.
NSString *post =[NSString stringWithFormat:@"comment=%@", myData];
NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
] NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:@"http://server.com/save-comment.php"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLResponse *response; NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"Data: %@",data);
精彩评论