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
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.