 |
 |
|
 |
01-31-2010, 12:12 PM
|
#1 (permalink)
|
|
Registered Member
Join Date: Jan 2010
Posts: 3
|
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.
|
|
|
01-31-2010, 12:27 PM
|
#2 (permalink)
|
|
Almost there
Join Date: Dec 2008
Location: Leeds, England
Posts: 621
|
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!
|
|
|
01-31-2010, 02:50 PM
|
#3 (permalink)
|
|
Registered Member
Join Date: Jan 2010
Posts: 3
|
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
|
|
|
01-31-2010, 03:21 PM
|
#4 (permalink)
|
|
Almost there
Join Date: Dec 2008
Location: Leeds, England
Posts: 621
|
Yeah, you should try to mimic it exactly.
Tom
|
|
|
01-31-2010, 04:34 PM
|
#5 (permalink)
|
|
Registered Member
Join Date: Jan 2010
Posts: 3
|
Cool, will do, thanks for the help!
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 322 |
| 39 members and 283 guests |
| blyther, CHV, Coppes, Corund, dannymichael, dany88, dcinqc, DrTyrell, Eskema, FlukeDude, gbh, giampo, harrytheshark, headkaze, Hololon, iphonedave, iSdkDev, iTrackiGiveaway, jazzbearz, JoyiPhone, kalygraphix, Lukapple80, MartinIngvar, mcgrath3, melmoup, miguel.campiao, Mopedhead, myPhone, norskben, orange gold, pereorra, Pilly170, rolypolyfishhead, shuz, soga, TheZimm, ToM, yunas |
| Most users ever online was 779, 05-11-2009 at 09:55 AM. |
» Stats |
Members: 24,242
Threads: 39,018
Posts: 171,141
Top Poster: smasher (2,570)
|
| Welcome to our newest member, DrTyrell |
|