PC Web Forms and Programs

These pages describe how to write World Wide Web forms and how to write PC executables which work with the NCSA httpd web server, using the Common Gateway Interface (CGI).

Isn't this already documented?

Yes, but I found that it was not clear at all. Here I give some practical tips which are worth passing on.

Also, I show how to write C programs that do the job, not just batch files or Visual Basic code.


What's Here

This page is a summary of the whole process of writing forms and programs, so follow all the links for full details.

First, you should get up to speed if you don't know about HTML or URLs. Then set yourself up with httpd.

Forms

Forms are in Web pages; they allow a user to fill in data and send it to the form server.

The key to forms is that a URL can point to a PC executable. When referenced, the executable is run and its HTML output is what you see.

When you write Form HTML you specify a URL that is run when the user has filled in a form. This URL will be your PC executable which receives the user's form data as its input.

Here's a picture of an HTML for this form.

This PC Forms Preamble gives some background on forms.

DOS-box Executables

You can write a DOS program to be your PC executable. This will run in a DOS-box created by httpd. However there are some limitations to DOS-box executables.

Windows Executables

It is better to write Windows executables.

httpd uses the Common Gateway Interface (CGI) to run both DOS-box and Windows programs. So our CGI programs are passed the CGI Data File when run.

To cut a long story short, here is a working Windows program and its actual C program code.

Here are some Hints on writing forms. You can set image maps to respond when a user clicks in an image. There is also information on the <ISINDEX> tag.

Finally, I discuss possible Applications.

Other environments

As an aside, you can also write CGI programs in other computer environments: the Bourne shell, C shell, PERL, the TCL argument processor as well as C, C++, Visual Basic and DOS batch files.

The Future

Several companies are working on commercial browsers which should get round some of the problems with Mosaic.

Also, there is a working group on the next generation of HTML, ie version 3.0, and an associated browser. You will be able to set up proper tables, and internationalise your pages. It may include OLE/OpenDoc style embedding within HTML documents - more efficient than CGI? Form fields should be improved, and client-side scripts can be associated with forms.

Conclusion

HTML forms are a good way of getting responses from users anywhere in the world, whatever their computer.

Writing PC programs that respond to forms, or provide real-time HTML, is pretty straight forward. Get connected!


Contact Chris Cant, PHD Computer Consultants Ltd <cant_c@nsa.bt.co.uk> or <good-tech@mcr1.poptel.org.uk>

7 February 1995