1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www...../scripts/newAnnonceID.php"]];
// On utilise une requète http POST
[request setHTTPMethod:@"POST"];
// On passe les variables
[request setHTTPBody:[[NSString stringWithFormat:@"mail=%@&nom=%@&telephone=%@&zipCode=%@&ville=%@&title=%@&annee=%@&km=%@&energie=%@&boite=%@&dscp=%@&price=%@",mail,nom,tel,Zipcode,ville,stTitre, stAnnee, stKm, stPrix, stEnergie, stDescription, stBoiteVitesse]dataUsingEncoding:NSASCIIStringEncoding]];
NSURLResponse *response;
// On récupère ce qui est renvoyé par le code php et on l'affiche.
NSData *returnXml = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *test = [[NSString alloc] initWithData:returnXml encoding:NSASCIIStringEncoding];
NSLog(@"Error: %@", [error localizedDescription]);
NSLog(@"result: %@", returnXml);
NSLog(@"test: %@", test); |
Partager