我正在制作一个lo-gin应用程序我想发送用户名和密码到服务器进行验证如何做到这一点我已经在很多方面做了,但我是无法发布。 我张贴的用户名和密码,但如果我直接给用户名和密码到PHP它的工作原理,以便如何做到这一点的iphone通过邮局发送如何发送用户名和密码使用发布到iphone服务器中的服务器
NSString *post = [[NSString alloc] initWithFormat:@"UserName=%@&Password=%@",username,pass];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSURL *url = [NSURL URLWithString:@"http://www.celeritas-solutions.com/emrapp/connect.php?"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPMethod:@"POST"];
theRequest setValue:postLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPBody:postData];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection)
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(@"Inside the else condition");
}
[nameInput resignFirstResponder];
[passInput resignFirstResponder];
nameInput.text = nil;
passInput.text = nil;
看一看[本S.O文章] [1]介绍了如何使一个POST请求。 [1]:http://stackoverflow.com/questions/3968107/http-post-request – sergio 2012-03-19 09:34:26
我已经看过这个相同的结果 – user1263350 2012-03-19 09:39:24
添加以下代码后 – Rupesh 2012-03-19 09:54:50