Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.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, 12: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, 12:27 PM   #2 (permalink)
Almost there
 
Join Date: Dec 2008
Location: Leeds, England
Posts: 621
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 online now   Reply With Quote
Old 01-31-2010, 02: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, 03:21 PM   #4 (permalink)
Almost there
 
Join Date: Dec 2008
Location: Leeds, England
Posts: 621
Default

Yeah, you should try to mimic it exactly.

Tom
harrytheshark is online now   Reply With Quote
Old 01-31-2010, 04: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
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


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,242
Threads: 39,018
Posts: 171,141
Top Poster: smasher (2,570)
Welcome to our newest member, DrTyrell
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:05 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0