I want to sent comment in controller to PHP site.
The following is my code for doing that:
NSString *word = _commentText.text;
NSString *user =[keychain objectForKey:(__bridge id)(kSecAttrAccount)];
NSSTring *post = 500 //webpage content site
if(word !=nil){
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Finished" message:@"Comment Finished" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
//NSString *filenames=[NSString stringWithFormat:@"TextLabel"];
NSString *postString = [[NSString alloc] initWithFormat:@"id=%@&no=%@&comment=%@",user,code,word];
NSData *myRequestData = [NSData dataWithBytes: [postString UTF8String] length: [postString length]];
NSMutableURLRequest *request =[[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:@"http://mylink.com/comment_upload2.php"]];
[request setHTTPMethod:@"POST"];
NSLog(@"%@",_commentText.text);
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
[request setHTTPBody: myRequestData];
NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil];
NSString *response = [[NSString alloc] initWithBytes:[returnData bytes] length:[returnData length] encoding:NSUTF8StringEncoding];
[NSURLConnection connectionWithRequest:request delegate:self];
NSLog(@"%@", request);
NSLog(@"%@",response);
NSData *retunData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc]initWithData:retunData encoding:NSUTF8StringEncoding];
[request setHTTPBody:[post dataUsingEncoding:NSUTF8StringEncoding]];
NSLog(returnString);
NSLog(@"Commented");
}//if
But when I touch on the comment, the comment does not appear in my site.