The Complete HTML Teacher

The Cgi-Bin And It's Uses





Ahh....CGI. You have left HTML and entered the Twilight Zone.

You aren't in Kansas anymore...well, maybe you are in Kansas?

Anyway. You now need to know about the cgi-bin, and what it is used for. This tutorial does not teach cgi or Perl programming. It just explains a little bit.

You need to first check with your webhosting service, and see if they offer a cgi-bin for your use. If they don't, you can sign up with a free cgi-bin host...which will actually simplify things a bit, as they give you codes to copy and paste for the various things that the cgi-bin is used for.

You can sign up with the following cgi-hosts...these two are the best:

CGI For Me

Bravenet

Now, if your webhosting server does offer you the use of a cgi-bin...you need to know what it is for, and how to use it.

First...CGI stands for "Common Gateway Interface". CGI scripts are written in either the Perl or C programming languages. Here is how it works:

The web browser..such as Netscape or Internet Explorer decodes the first part of the URL and contacts the server. Once the server is contacted, the browser tells the server the rest of the URL. For instance, if you used a URL such as: http://www.whatever.com/cgi-bin/FormMail.cgi, the browser would first look for http://www.whatever.com. Once it found that, it would tell the server to find /cgi-bin/FormMail.cgi.

The server then translates the supplied URL into a path and file name. When the server sees the .cgi on there, it knows that the URL points to a program instead of a static file. The server then prepares the environment, and launches the script. The script executes and does what it was programmed to do.

Wasn't that boring?

Well, that's how it works...but now what is it for?

First, you need to know that each server is different when it comes to where the cgi scripts reside. Some require that all of your cgi scripts are put into one folder...called the cgi-bin. With other servers, a cgi-bin isn't necessary, and you can upload your scripts just like you would any other file...except the script will have an extension of .cgi instead of .html, .htm. or .gif .jpg, etc.

If your server requires that your scripts are kept in a separate directory, you simply create the directory through your ftp client, or use the file manager that your webhosting service provides. You want to "create a new directory", and name that directory "cgi-bin"(without the quotes).

Cgi scripts are used for classified ads, free for all links, forms, guestbooks, counters, message boards, and a host of other things.

Luckily for all of us, this is The World Wide Web...home of information, misinformation, and lots of free information and misinformation. You can get free cgi scripts. Check with Matt's Script Archive. The chances are very good that Matt will have the scripts you want...and if by chance he doesn't, simply do a search in any search engine for "cgi scripts".

And if you're up to it, go over to MacMillan Publishing's Online Books, register for free, and check out an online book that teaches Perl and Cgi Programming.

What Happened To The Easy Stuff?

Contents



Copyright ©1998 by K. Williams Resources. All Rights Reserved