Recent

Author Topic: Access WEB form  (Read 5473 times)

christensen

  • Full Member
  • ***
  • Posts: 127
Access WEB form
« on: November 26, 2015, 07:14:47 pm »
Hi,

Until this moment i haven't deal with web interfaces, now i want to access a webpage (link) and field some fields (two fields) and submit.

How can i write in those fields and execut the submit?
What component i sould use.

Any help will be appreciate as i never work with network components.

Thanks
Lazarus 1.4.4, FPC 2.6.4, Windows 7 64bit, AMD Athlon 7750 black edition, Asus M3N78-CM
Lenovo L540 i7-4702MQ, Windows 10 x64,Lazarus 1.6.2,FPC 3.0

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Access WEB form
« Reply #1 on: December 05, 2015, 12:15:03 am »
Probably Synapse, and especially one called synalist that includes ssl_openssl.pas.

But if you want more advice, I would want more details.

Like: your platform (Windows x, Linux y, Apple z), what exactly you want to do with that website, and if you are also the person managing that website.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Access WEB form
« Reply #2 on: December 06, 2015, 06:41:03 pm »
You don't really need a component, you need to read and understand how http protocol works. Once you get it, any networking library with http support (including but not limited to the pre-installed fcl-web units) will do.

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: Access WEB form
« Reply #3 on: December 06, 2015, 06:49:46 pm »
If it is your website then it is really very easy to execute this task. Its upto your preference that which library you will like to choose, whether fcl-web, inet, indy or synapse.

Add required controls on your form and. Use any of these library to send the forms data to your webpage using the get/post methods. And when you receive that data on your webpage, do what-ever you like, its that simple.
Holiday season is online now. :-)

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1314
    • Lebeau Software
Re: Access WEB form
« Reply #4 on: December 09, 2015, 11:37:44 pm »
How can i write in those fields and execut the submit?
What component i sould use.

If you use Indy, its TIdHTTP component can be used to submit an HTML webform (a <form> element and <input> fields) to an HTTP server.

If the <form> "enctype" attribute is omitted, or set to "application/x-www-form-urlencoded":

Code: Pascal  [Select][+][-]
  1. var
  2.   Http: TIdHTTP;
  3.   Input: TStringList;
  4. begin
  5.   Http := TIdHTTP.Create;
  6.   try
  7.     Input := TStringList.Create;
  8.     try
  9.       Input.Add('name=value');
  10.       ...
  11.       Http.Post('http://server/script', Input);
  12.     finally
  13.       Form.Free;
  14.     end;
  15.   finally
  16.     Http.Free;
  17.   end;
  18. end;
  19.  

If the <form> "enctype" attribute is set to "multipart/form-data":

Code: Pascal  [Select][+][-]
  1. var
  2.   Http: TIdHTTP;
  3.   Input: TIdMultipartFormDataStream;
  4. begin
  5.   Http := TIdHTTP.Create;
  6.   try
  7.     Input := TIdMultipartFormDataStream.Create;
  8.     try
  9.       Input.AddFormField('name', 'value');
  10.       ...
  11.       Http.Post('http://server/script', Input);
  12.     finally
  13.       Form.Free;
  14.     end;
  15.   finally
  16.     Http.Free;
  17.   end;
  18. end;
  19.  
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

bee

  • Sr. Member
  • ****
  • Posts: 393
Re: Access WEB form
« Reply #5 on: December 10, 2015, 04:32:41 am »
For simple tasks, using a library is overkill. Web app is very simple, some readln and writeln are enough. I have some examples here: http://beeography.koding.io/viewcode.cgi. No external libraries required, just basic Pascal and some RTL. You could take a look at the source code and you could also run the app. Good luck! :)
-Bee-

A long time pascal lover.

BeniBela

  • Hero Member
  • *****
  • Posts: 908
    • homepage
Re: Access WEB form
« Reply #6 on: December 10, 2015, 01:48:21 pm »
Or full overkill with my Internet Tools:
Code: [Select]
query('form((doc("http://server/link")//form)[1], {"name": $_1})', ['value']).retrieve();
and you do not need to care about the enctype, since it checks for that.

 

TinyPortal © 2005-2018