views:

28

answers:

1

hi all. 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 their 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.

+1  A: 

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);

Arun Sharma
Arun Thanks for your reply.....but how to communicate with remote database their is other feature for which i also have to code like remote signup login rate article etc...............
Nauman.Khattak
u make a php page which create a connection to ur server database and take arguments like comments,article and save to ur server database.and u can post data and get data as coded above.
Arun Sharma