Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TWebBrowser postdata

Posted on 2008-10-16
2
Medium Priority
?
1,132 Views
Last Modified: 2012-06-27
I need to open a new web page from a  program in delphi
 and send  post  login info
example postdata will be pass=pass login=login

WebBrowser1.OleObject.Navigate('http://xxxxxx.com/testme.php',1,'', postdata);

opens the page but sends no postdata
how is this done?
i am looking for any way in delphi to open a new browser and send the postdata



0
Comment
Question by:arotton
2 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 2000 total points
ID: 22733714
here are some link explaining and showing how it's done via IE:
with twebbrowser: http://dn.codegear.com/article/26531
with url api: http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_21249531.html
and uploading files too: http://delphi.about.com/od/delphitips2007/qt/httppost_delphi.htm

and using indy, you can find some on my site. they are specifically persistent login examples in various sites. the idea with indy is that you need to manage cookies by yourself, somthing IE does automatically for you ;) but if you don't need the overhead of IE, then indy can be a solution:
http://www.ciuly.com/delphi/indy/
0
 

Author Comment

by:arotton
ID: 22734899
yes the link
 http://dn.codegear.com/article/26531
was what i am looking for
------
procedure TForm1.Button5Click(Sender: TObject);
var
  EncodedDataString: string;
  PostData: OleVariant;
  Headers: OleVariant;
  I: Integer;
begin
  // First, create a URL encoded string of the data
  EncodedDataString := 'login=login'  +   '&pass=sss'   ;

   // The PostData OleVariant needs to be an array of bytes as large
  // as the string (minus the NULL terminator)
  PostData := VarArrayCreate([0, Length(EncodedDataString) - 1], varByte);
  // Now, move the Ordinal value of the character into the PostData array
  for I := 1 to Length(EncodedDataString) do
    PostData[I-1] := Ord(EncodedDataString[I]);
  Headers := 'Content-Type: application/x-www-form-urlencoded' + #10#13;
  // Finally, we just Navigate to the URL. Note that you may have to modify
  // the path to your ASP page's location.
  WebBrowser1.Navigate('http://xxxxx.com/testme.php', 1,EmptyParam, PostData, Headers);
end;

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Integration Management Part 2
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question