Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 09-24-2009, 11:38 PM   #1 (permalink)
encryption
Registered Member
 
Join Date: Sep 2009
Posts: 48
encryption is on a distinguished road
Question Help with HTTP Post using ASIFormDataRequest

Hello,

I'm working on a network game... and well the networking part is stalling....

I have a logon UIView with a logon UIButton that starts the following action in its ViewController:

Code:
- (IBAction) login: (id) sender
{
	// GUI Updates
	loginIndicator.hidden = FALSE;
	[loginIndicator startAnimating];	
	loginButton.enabled = FALSE;

	// Connect to server for authentication !!! WARNING !!! this is a synchronous request, blocking

	ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.mysecrutserver.com/cgi-bin/auth.pl"]] autorelease];
	
	// Setup Agent
	[request addRequestHeader:@"User-Agent" value:@"ASIHTTPRequest"];

	[request setPostValue:usernameField.text forKey:@"user_name"];
	[request setPostValue:passwordField.text forKey:@"password"];
	[request start];

	if ([request error])
	{
		// Error throw an alert ** Could not logon to game server **
		UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Could not logon to game server" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
		[alert show];
		[alert release];
	}
	else if ([request responseString])
	{
		// A valid http request, but it the server curently does not see the post vars in the web application
		NSLog (@"[DEBUG]: HTTP Response is %@",[request responseString]);
	}
}
I am connecting to the Apache web server but this code does not pass the user_name or password fields to the script running there. usernameField and passwordField are variables linked to the the text fields in the login view.

Can anyone please help me? I've Googled my fingers numb and I cannot find a solution. Most every article is asking about uploading images. Forget images I'd be happy to simply pass along a few text values!

Thanks in advance!

Encryption,
Nick Powers
encryption is offline   Reply With Quote
 

» Advertisements
» Online Users: 897
21 members and 876 guests
ADY, Alexj17, BinHex, chinh.vu, chits12345, deeptika, gogoman, iOS.Lover, iShailesh, jbro, kosicki123, lynngobin, mohamed khairy hassa, Mp808, myach, Renrob, Rikco, SDP, Steve Crown, trisvandis, zbynda
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,281
Threads: 93,957
Posts: 402,307
Top Poster: BrianSlick (7,971)
Welcome to our newest member, SDP
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:19 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.