My iPhone app communicates through a php file with my mySql database. Everything works fine. But when I send the form and the username already exists, the php file should somehow backfire a notification. What should I do ?
php File
$query = "SELECT username FROM userData WHERE username = '$username'";
$result = mysql_query($query);
if (mysql_num_rows($result) > 0) {
// WHAT SHOULD BE DONE HERE TO NOTIFY iPHONE ?
}
I could think of a way, but it I think there is a better and more efficient way to do it.
[EDIT]
This is what I did to get the response:
NSURLResponse *theResponse =[[NSURLResponse alloc]init];
NSError *error;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&theResponse error:&error];
NSDictionary *jsonDictionaryResponse =[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSLog(@"json response = %@", jsonDictionaryResponse);
[/EDIT]
He does not really need a push notification. Just need a response back from the server.
Where sendResponse looks like this
// Helper method to send a HTTP response code/message