INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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.

Jobs

Delphi, PHP and MySQL

How do I design the protocol to transfer data between server and client? by towerbase
Posted: 27 Jul 04

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.
 


 

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

My Archive

Resources

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