Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I design the protocol to transfer data between server and client?

Delphi, PHP and MySQL

How do I design the protocol to transfer data between server and client?

by  towerbase  Posted    (Edited  )
A protocol is simply a set of rules. It is important to design the protocol before coding the Delphi program or the PHP script.

Think about what we are trying to do. We want the Delphi program to send a day and a month to the PHP script which will then query the MySQL table to obtain the names of all the people who were born on that day and month. We then want the PHP script to send a list of names back to the Delphi program. The list may contain zero or more names.

So we need to send the PHP script a day number and a month number. Let's decide upon the name of the PHP script. We'll call it 'birthdays.php'. Now if you type the following into your web browser you will get a response indicating that you haven't submitted any parameters

www.pealbase.34sp.com/birthdays.php

The way you submit parameters is to append a question mark and then a name-value pair. Subsequent parameters are prefixed by an ampersand. So our request for a list of names that were born on 24th July would be

www.pealbase.34sp.com/birthdays.php?day=24&month=7

It is a good idea to write this down as both the Delphi program and the PHP script have to use this protocol.

Now we could return the data in a number of ways. But a good way is to return the data as a web page because this can be displayed and checked by using a web browser and without going near Delphi.

So the returned web page will consist of zero or more names within paragraph tags. For example:

<p>Alan Shearer</p>
<p>Laurent Robert</p>

Of course the other usual HTML code will surround these paragraph tags in the returned web page.

And that's all there is to this birthday protocol. It might be a good idea to enhance the protocol to specify what happens if an invalid day or month is supplied but I will leave that to you.



Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top