Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Delphi, PHP and MySQL

How do I write the client side Delphi code to send a request and process the returned data? by towerbase
Posted: 27 Jul 04 (Edited 26 Jun 06)

Let's recap.  Your Delphi code has to send a request to the web server to ask for a list of people having a birthday on a specific date.  Your code has to then process the returned data and display it on a form.  For the purposes of this exercise we will put the list of names in a StringList.

So the request that we wish to send to the server is something like:


How do we send that to a web server?  It is surprisingly easy if you have the Indy components (supplied with Delphi 6 and 7).  The hardest part is finding the right Indy component because there are dozens of them!

The component you want is TIdHTTP which is on the Indy Clients tab.  It's icon is a blue globe and is 11th from the left in my IDE.

Drop this on your form. Set the name property to HTTP. Drop a TButton on the form and in the OnClick handler for the button code the following:


  URL = 'http://www.towerbase.34sp.com/birthdays.php?day=%d&month=%d';
  command: string;
  response: string;
  command := Format ( URL, [ DayOf(Now), MonthOf(Now) ] );
  response := HTTP.Get ( command );
  ExtractNames ( response );

To keep things simple, I've assumed you want a list of people whose birthday is today.  But you could make it more flexible by dropping a Calender on the form and using that to select a date.

The response variable will contain the entire HTML for the web page.  In particular it will contain the names we want embedded within paragraph tags.  

The ExtractNames routine would extract the names from within these tags and add them to a string list.  This task is made particularly easy because each <p> starts on a new line, followed by a line containing the name followed by a line containing the </p>.

If you want to try this out then you can use the URL supplied above.

Back to Embarcadero: Delphi FAQ Index
Back to Embarcadero: Delphi Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close