Posting to an URL

I want to open mi Internet Explorer from a delphi application to a url that needs passing of some parameters.  The problem is that the page accepts the parameters if they a sent from a html form using post method.

Does anyone know how to do it?
clopezAsked:
Who is Participating?
 
SeregaConnect With a Mentor Commented:
In that case I think you should to use WebBrowser control. It has a lot of methods and it is possible to do your task with it.
0
 
craig_capelCommented:
edit1.text:='www.experts-exchange.com';
shellExecute(handle,'open',pchar(edit1.text),'','',0);

to send out an url.....


ShellExecute(Application.Handle,PChar('open'),PChar('mailto:name@usa.net'),PChar(''),nil,SW_NORMAL);

This opens the default mail browser and gets the email ready

hope that helps...


Craig C.
0
 
geobulCommented:
Hi,
Does your URL contain script?
Do you know the names of these parameters (as they are in the previous html form)?

Regards, Geo
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
clopezAuthor Commented:
To craiq capel, your answer doen't send parametes using post method.  I justs opens the explorer
0
 
clopezAuthor Commented:
Geobul,

I think that that URL may have an script, but it must be in the server side.  In the resulting page there is no code.

The previous form looks like this:

<form method="POST" action="myacct.asp" name="login_form">
<input type="hidden" name="loc" value="">
ID: <input type="text" name="id" size="6" maxlength="6"><br>
Password: <input type="password" name="password" size="12" maxlength="12">
<input type="image" src="images/login.gif" border="0" value="submit" WIDTH="69" HEIGHT="43" id="image1" name="image1">
</form>

Also it may be important to say that is a secure page.
0
 
SeregaCommented:
I think using parameters in the url would be acceptable. For example:
edit1.text:='www.experts-exchange.com?password=password&text=sometext';
and open a browser with that url.
0
 
clopezAuthor Commented:
Sorry Serega, that doesn't work
0
 
clopezAuthor Commented:
Any idea on how to do it?
0
 
SeregaCommented:
I don't know exactly how to do it. Try to search at EE for a word: WebBrowser.
Or see at http://www.euromind.com/iedelphi/getting_started.htm
0
 
geobulCommented:
Hi,
Sorry for the late reply.
Now to the question:
1.Create a file 'c:\temp\start.html' on the local disk.
2.Write the following in the file:
---Cut---
<HTML>
<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!--
function geo()
{
  login_form.OKBtn.click();
}
//-->
</SCRIPT>

</HEAD>
<BODY onLoad="geo()">

<form method="POST" action="myacct.asp" name="login_form">
<input type="hidden" name="loc" value="">
ID: <input type="text" name="id" size="6" maxlength="6" value="l_name"><br>
Password: <input type="password" name="password" size="12" maxlength="12" value="l_pass">
<INPUT TYPE=submit NAME="OKBtn">
</form>

</BODY>
</HTML>
---Paste---

Replace 'l_name' and 'l_pass' with your values. Add the full URL in form.action = "http://.../myacct.asp".
3.Close the file
4.Start the browser with this file

Regards, Geo
0
 
geobulCommented:
Are you still here ?
0
 
clopezAuthor Commented:
Sorry for the delay,
I am still trying to make it work.  For some reason it seem not work when requested from a file or using the webbrowser. Promess to give more info or accept an answer this weekend.
0
 
clopezAuthor Commented:
I think the page is detecting where the information page comes from or there is a problem with the page beeing secure.

Anyway, so this doesn't take longer I will accep Serena's aproach as a valid answer, because it was the first person to give an near solution, and also because I think is a better programing solution than geobul.

Also I wuold like to stat that geobul solution may also work in a similar case and I would like to thank all of you for you help.

For future look up the way to pass the parameters with the WebBrowser is:

procedure TForm1.CallURL(URL,Param1,Param2:string);
var Data:string;
   a, b, c, d: OLEVariant;
   i, ib: integer;
   ch: char;
   pp: PChar;

begin
   Data := 'Param1='+ Param1+ '&Param2='+Param2;
   a := 1;
   b := 0;
   ib := Length(Data);
   c := VarArrayCreate([0, ib], 17);
   pp := PChar(Data);
   for i := 0 to ib do
   begin
      ch := pp[i];
      c[i] := ord(ch);
   end;
   d := 'Content-Type: application/x-www-form-urlencoded' + #13 + #10;
   WebBrowser1.Navigate(URL, a, b, c, d);
end;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.