iCulture forum | iPhone, iPad,  iPod touch, Apple TV en iOS

iCulture forum | iPhone, iPad, iPod touch, Apple TV en iOS (https://forum.iculture.nl/)
-   Ontwikkelen voor iOS (https://forum.iculture.nl/f133/development/f58/ontwikkelen-voor-ios/)
-   -   Data uploaden (https://forum.iculture.nl/f133/development/f58/ontwikkelen-voor-ios/53050-data-uploaden.html)

Tim14ww 29-01-10 17:08

Data uploaden
 
Hoi,

Ik probeer data te uploaden in m'n database, met de volgende code:

Code:

-(IBAction)update{
                NSString *post = @"key1=val1&key2=val2";
                NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
               
                NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
               
                NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
                [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.marvinvdgraaff.nl/onsys/test.php?naam=%@",[userName text]]]];
                [request setHTTPMethod:@"POST"];
                [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
                [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                [request setHTTPBody:postData];
               
                NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:request delegate:self];
                if (conn)
                {
                        NSLog(@"Gelukt!");
                }
                else
                {
                        // inform the user that the download could not be made
                        NSLog(@"Mislukt!!");
                }
               
        }

[userName text] is dus het textfield dat ik verzonden wil hebben, maar nu krijg ik dus in m'n database een leeg veld aan, dus wat doe ik fout?

moet ik niets veranderen aan: NSString *post = @"key1=val1&key2=val2"; ??

Alvast bedankt,

Tim!


Alle tijden zijn GMT +2. Het is nu 14:43.