-(void) registerintoserverDB{
NSString *str_registerURL = @"reg_action.php";
NSString *str_completeURL = [NSString stringWithFormat:@"%@%@", str_global_domain, str_registerURL];
NSURL *url = [NSURL URLWithString:str_completeURL];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60];
[theRequest setHTTPMethod:@"POST"];
[theRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSString *str_address = [NSString stringWithFormat:@"%@%@", txt_address1.text, txt_address2.text];
NSString *postData = [NSString stringWithFormat:@"rest_name=%@&rest_telephone=%@&rest_email=%@&rest_password=%@&rest_country=%@&rest_city=%@&rest_postal=%@&rest_delivery=%@&rest_address=%@&rest_image=%@&rest_minimum_order=%@&isUser=%@&fb_name=%@fb_like", txt_restaurantname.text, txt_telephone.text, txt_email.text, txt_pass.text, txt_country.text, txt_city.text, txt_postal.text, txt_deliveryHours.text, str_address, @"imagepath", @"10 euro", @"Yes", str_global_user_fbUsername];
NSString *length = [NSString stringWithFormat:@"%d", [postData length]];
[theRequest setValue:length forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPBody:[postData dataUsingEncoding:NSASCIIStringEncoding]];
NSURLConnection *sConnection = [NSURLConnection connectionWithRequest:theRequest delegate:self];
[sConnection start];
NSData *responseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil];
NSLog(@"response data is %@", responseData);
NSString *returnString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"returnString....%@",returnString);
NSDictionary *response_dic = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:nil];
NSLog(@"msg is : %@ ",[response_dic objectForKey:@"msg"]);}
我想将用户详细信息插入服务器端数据库,所以我使用了这段代码,它工作正常,但问题是在我的服务器数据库中,重复的条目被插入,就像 2 条具有相同详细信息的记录无法准确识别问题出在哪里在我的代码端或服务器端。请尽快提出一些指导方针。提前致谢!