@@ -269,23 +269,30 @@ - (IBAction)checkout:(id)sender{
269269 UIAlertView *alert = [[UIAlertView alloc ] initWithTitle: @" Order Placed" message: @" Your order will be ready in 1 minute."
270270 delegate: self cancelButtonTitle: @" OK" otherButtonTitles: nil ];
271271 // Build a URL Request of the ordered items to Matt can show it.
272- // NSString *post = @"";
273- // for(NSDictionary *item in basket){
274- // post = [post stringByAppendingString:[item objectForKey:@"itemTitle"]];
275- // post = [post stringByAppendingString:@","];
276- // }
277- // NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
278- // NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
279- //
280- // NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
281- // [request setURL:[NSURL URLWithString:@"http://www.nowhere.com/sendFormHere.php"]];
282- // [request setHTTPMethod:@"POST"];
283- // [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
284- // [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
285- // [request setHTTPBody:postData];
286-
287- // NSLog(@"post = %@", post);
288- [alert show ];
272+ NSString *post = @" item=" ;
273+ for (NSDictionary *item in basket){
274+ post = [post stringByAppendingString: [item objectForKey: @" itemTitle" ]];
275+ post = [post stringByAppendingString: @" ," ];
276+ }
277+ NSData *postData = [post dataUsingEncoding: NSASCIIStringEncoding allowLossyConversion: YES ];
278+ NSString *postLength = [NSString stringWithFormat: @" %d " , [postData length ]];
279+
280+ NSMutableURLRequest *request = [[[NSMutableURLRequest alloc ] init ] autorelease ];
281+ [request setURL: [NSURL URLWithString: @" http://dlzip.com/food/order.php" ]];
282+ [request setHTTPMethod: @" POST" ];
283+ [request setValue: postLength forHTTPHeaderField: @" Content-Length" ];
284+ [request setValue: @" application/x-www-form-urlencoded" forHTTPHeaderField: @" Content-Type" ];
285+ [request setHTTPBody: postData];
286+
287+ NSURLConnection *connectionResponse = [[NSURLConnection alloc ] initWithRequest: request delegate: self ];
288+ if (!connectionResponse) {
289+ NSLog (@" Failed to submit request" );
290+ } else {
291+ NSLog (@" Request submitted" );
292+ }
293+
294+ NSLog (@" post = %@ " , post);
295+ [alert show ];
289296 [alert release ];
290297
291298 // clear list
0 commit comments