pass variables from iOS app to web site


/ Published in: Objective C
Save to your folder(s)

pass variables from iOS app to web site (synchrone version)


Copy this code and paste it in your HTML
  1. //SommeBD and other are int
  2. NSString *post = [NSString stringWithFormat:@"identifiant=%d&sbd=%d&sr=%d&sv=%d&spg=%d", [identifiantUniqueString intValue], sommeBD, sommeR, sommeV, sommePB];
  3. NSString *hostString = @"http://www.mywebsite/putItInMyDataBase.php?";
  4. hostString = [hostString stringByAppendingString:post];
  5.  
  6. NSData *dataFromURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:hostString] options:NSDataReadingUncached error:&error];
  7. if(error)
  8. {
  9. NSLog(@"%@", [error localizedDescription]);
  10. }
  11. else
  12. {
  13. NSLog(@"Data had loaded successfully");
  14. }
  15. NSString *resultString = [[NSString alloc] initWithData:dataFromURL encoding:NSUTF8StringEncoding];
  16.  
  17. /* In php code
  18. <?php
  19.  
  20. $identifiant = $_GET['identifiant'];
  21. $sommeBD = $_GET['sbd'];
  22. $sommeR = $_GET['sr'];
  23. $sommeV = $_GET['sv'];
  24. $sommePbG = $_GET['spg'];
  25.  
  26.  
  27. updateBdd($identifiant, $sommeBD, $sommeR, $sommeV, $sommePG);
  28.  
  29. echo '0';
  30. ?>
  31. */

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.