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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-31-2010, 01:12 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 3
Default Fill in HTML form automatically?

Hi All,

I am trying to (transparent to the user) fill in a html form a press submit. I am trying to prevent the user having to log in every time they visit the page so I intend to store their password and then pass it to the form when needed. Does anybody have any idea how I could achieve this.

Code:
Username: <INPUT TYPE="text" NAME="user_id"  SIZE=25 MAXLENGTH=50 tabindex="1">
Password: <INPUT SIZE="25" NAME="password" TYPE="password" tabindex="2">
That is an example of the form I am trying to fill in and the submit button would be as follows:
Code:
<input type="image" alt="Log In" name="Login" src="/images/ci/formbtns/login_off.gif" tabindex="3" border="0">
Any help on this would be brilliant and I have been trying to come up with a solution for some time,

Thanks,

Callaghan001.
callaghan001 is offline   Reply With Quote
Old 01-31-2010, 01:27 PM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

When your web browser submits a form, what it's doing is posting the values for the fields in this format:

"name1=value1&name2=value2", so in this case "user_id=whatever&password=whatever".

You'll need to gather where the form is submitted (it's in the HTML source code, usually called the "action" or something like that), then you need to post the data yourself.

A very simple example of this would be something like:
Code:
NSString * postString = [NSString stringWithFormat: @"user_id=%@&password=%@",theUserName,thePassword];
NSData *myRequestData = [NSData dataWithBytes:[postString UTF8String] length:[postString length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString: @"http://www.theaddress.com"]]; 
[request setHTTPMethod:@"POST"];
[request setHTTPBody:myRequestData];
NSData * response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
[request release];
Hope that helps!
harrytheshark is offline   Reply With Quote
Old 01-31-2010, 03:50 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 3
Default

That helps a lot and I think it may be the way to go, but one question though, I think the webpage calls some javascript on the the entries before sending them back to the server, I think some base64 encoding and MD5...should I be worried about that too?

Thanks for the help,

Callaghan001
callaghan001 is offline   Reply With Quote
Old 01-31-2010, 04:21 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Yeah, you should try to mimic it exactly.

Tom
harrytheshark is offline   Reply With Quote
Old 01-31-2010, 05:34 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 3
Default

Cool, will do, thanks for the help!
callaghan001 is offline   Reply With Quote
Old 04-12-2010, 05:35 AM   #6 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 1
Default

That helps a lot and I think it may be the way to go, but one question though,
__________________
mcpd and mcts braindumps as well available for N10-004 from testking
williamsmith is offline   Reply With Quote
Reply

Bookmarks

Tags
html form, uiwebview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 158,484
Threads: 89,093
Posts: 380,131
Top Poster: BrianSlick (7,091)
Welcome to our newest member, lavernwatts
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:58 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0