在iOS中使用post方法,通过php web服务调用在服务器上保存注册视图控制器文本值



我有一个注册表格,里面有名字、姓氏、性别、电子邮件、密码、用户图像、年龄等字段。我想通过php-webservice调用将这些用户信息保存在服务器上。如何将这些参数传递到服务url?我会使用post方法使用http请求将用户信息保存到服务器吗?当该用户想要登录iOS应用程序时,我可能会为该用户匹配凭据。在岸上,我需要一个iOS应用程序的登录和注册屏幕,请建议我任何教程

提前感谢大家

首先需要创建php脚本,然后通过NSURL传输数据。

NSURL * url=[NSURL URLWithString:[NSString stringWithFormat:@"http://192.168.0.6/savedevicedata.php?Udid=%@&Flag=%d&DateTime=%@",uniqueIdentifier,Flag,FinalDate]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    NSLog(@"%@",request);
    [request setHTTPMethod:@"POST"];
    //[request setHTTPBody:[NSString stringWithFormat:@"%@",rawStr]];       
    NSURLResponse *response;
    NSError *err;
    NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
    NSLog(@"responseData: %@", responseData);

试试这个代码只是替换你的字段。

最新更新