Solved

TWebBrowser postdata

Posted on 2008-10-16
2
1,104 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 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

Title # Comments Views Activity
delphi exception 7 68
Working this component WebCopy with proxy, help 3 92
PHP preg_replace code convert to Delphi 14 68
delphi popmenu non latine charcters 3 13
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

820 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