I've successfully sent a POST request to my server but I want to know how to send a response from PHP
without using JSON objects or the database. I was thinking I could always send the database row values for the particular entry to my application and then compare them to see if the values match, but that seems a little verbose and undesirable. I'd much rather send an HTTP POST response from my PHP
script, if the log is correct which would contain a boolean variable depending on whether the encrypted passwords matched. I've looked all over the place but I can only find information about sending HTTP POST requests from the application, not receiving them from a PHP script on a server.
Edit: Here is an IBAction
which I'm using to open the connection to send data with POST.
NSString *registrationPOSTMessage = [NSString stringWithFormat:@"username=%@&password=%@&emailAddress=%@",self.registrationFieldUsername.text,self.registrationFieldPassword.text,self.registrationFieldEmail.text];
NSData *ASCIIEncodedRegistrationPOSTData = [registrationPOSTMessage dataUsingEncoding:NSASCIIStringEncoding];
NSString *ASCIIEncodedRegistrationPOSTDataLength = [NSString stringWithFormat:@"%ul",(unsigned)[ASCIIEncodedRegistrationPOSTData length]];
NSMutableURLRequest *registrationRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.hausofalexander.tk/someiOSApplication/Register.php"]];
[registrationRequest setHTTPMethod:@"POST"];
[registrationRequest setHTTPBody:ASCIIEncodedRegistrationPOSTData];
[registrationRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[registrationRequest setValue:ASCIIEncodedRegistrationPOSTDataLength forHTTPHeaderField:@"Content-Length"];
NSURLConnection *registrationConnection = [[NSURLConnection alloc] initWithRequest:registrationRequest delegate:self];
if (registrationConnection) {
NSLog(@"The registration information has been sent! :D");
} else if (!registrationConnection) {
NSLog(@"For some reason the registration information couldn't be sent. :(");
} else {
NSLog(@"Something horrible has happened :|");
}