Solved

TWebBrowser postdata

Posted on 2008-10-16
2
1,107 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

759 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