I am trying to create a login system on an iPhone app but am coming across a bit of a problem. I believe that the code I have is sending the the NSString to the php but it is not echoing back the string like I want it to. What am I doing wrong?
I know the php code isn't doing much right now I just want to see that it is storing the values that I send it.
Thanks!
XCode:
NSString *content = @"myusername=a&mypassword=s";
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://mywebsite.php"]];
urlRequest = [[[NSMutableURLRequest alloc] init] autorelease];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setHTTPBody:[content dataUsingEncoding:NSISOLatin1StringEncoding]];
// generates an autoreleased NSURLConnection
[NSURLConnection connectionWithRequest:request delegate:self];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(returnString);
}
PHP:
echo "first ". $_POST['myusename']." return";
echo "second ". $_POST['mypassword']." return";