Re: Delphi: Send Login and Password to URL


[ Delphi Forum -- by DelphiLand ]

Posted by neo_aj on December 04, 2003 at 08:03:14:

In Reply to: Re: Send Login and Password to URL posted by webmaster Guido on July 12, 2003 at 18:59:04:

: : How do I sent a login string and password string from a link on a Menu Item?

: : thanks,
: : JB
: ----------------------

: Let's set up a form with 3 Edit boxes:

: - edLogin: for the login;
: - edPassword: for the password;
: - edPage: for the address of the page (without the "http://" part).
:
: Additionally, there's a button to initiate the login, named btnLogin, and there's a label named lblReturn, to show if there was an error.

: The code for the OnClick event of the button for accessing a password protected webpage is as follows:

: procedure TForm1.btnLoginClick(Sender: TObject);
: var
: Login, Password, WebPage, LogText: string;
: Return: integer;
: begin
: Login := edLogin.Text;
: Password :=edPassword.Text;
: WebPage := edPage.Text;
: LogText := 'http://' + Login + ':' + Password + '@' + Webpage;
: Return := ShellExecute(Handle, 'open', PChar(LogText), nil, nil, SW_SHOW);
: // If Return > 32 then it's OK, otherwise there was an error
: // For values of Return, see: API help, ShellExecute
: if Return > 32 then
: lblReturn.Caption := 'OK, done'
: else
: lblReturn.Caption := IntToStr(Return);
: end;
:
: Example: to access http://www.test.com with the login "abc" and the password '123', you would enter this in the edit-boxes:

: - edLogin: abc
: - edPassword: 123
: - edPage: www.test.com

: NOTE: add "SHELLAPI" to the USES statement of the form, otherwise Delphi won't find the ShellExecute function.

--------------------------------------------------------------------

i tried, but it didn't do anything. i have a login page return by asp. when i runing these code, it only open a ie without log me on


Related Articles and Replies:


[ Delphi Forum ]
[ DelphiLand: free Delphi source code, tips, tutorials ]