Advertisement
Tech

What You Need to Know About CGI Scripts for Forms

If you are a web designer, and you frequently design web forms, you’ll know that HTML alone is not enough to make your forms functional. You need other applications that will process your form submissions and in this article we examine CGI scripts for forms.

By Ossy Uche
Desk Tech
Reading time 3 min read
Word count 540
Web development Internet Intermediate tutorials
What You Need to Know About CGI Scripts for Forms
Advertisement
Quick Take

If you are a web designer, and you frequently design web forms, you’ll know that HTML alone is not enough to make your forms functional. You need other applications that will process your form submissions and in this article we examine CGI scripts for forms.

On this page

A Little Background

If you have experience with building web sites, you will know that you can use any HTML editor or a mixture of other tools to create web pages. To have a website online is simply a matter of uploading the page to the right place on the web server and voila! Your website is up and working. However when you begin working with HTML forms, things won’t be that simple anymore. Sure, you can design your forms using any HTML editor but you can’t get the form to do anything simply with HTML. You need something extra such as CGI scripts for forms.

You will also find that after designing a fantastic looking form with your HTML editor and uploading it to your website, you fill out the form inputs and click the submit button…..and nothing happens! In reality for you to get a form working it simply won’t suffice to just design the form itself in HTML, you also have to create a form processor script and point the form to it. The form processor is called a CGI script for forms and CGI simply stands for Common Gateway Interface. It runs on the web server and takes the data entered in the web form by the user and processes it.

Advertisement

CGI Script and Forms

What the CGI script does with the web form basically depends on the complexity of the form. In the case of a simple contact form, the CGI script for forms processor may do nothing but send the information entered in the form to an email address. (Usually contact forms are used to hide the recipient’s actual email address, as exposing it on the website may result in tons of spam). But for a more advanced application, the CGI script form processor would be a very complex program which ties in with the database and carries out an assortment of functions.

CGI scripts are never a part of the HTML but rather separate programs that are installed on the web server. The location of the form processor is spelt out in the HTML codes in this manner:

Advertisement

The above code shows where the CGI script is located and must be installed and set up on your web server.

After designing a web form with any HTML editor to let our browser recognize where to forward the content of the form we need to add these properties:

Advertisement
tag: action = address, method = post or method = get

The address is the location of the CGI script for forms on the web server that the content should be sent to, while the post and get methods are simply other ways of submitting to the CGI form script.

CGI Script for Forms Example

Let’s look at a typical form tag with action and method specified as well as the location of the CGI script specified.

Advertisement

cgi-for-forms
cgi-for-forms

Where: = https://www.myhostings.com/cgi-bin/formail.cgi is the location of the CGI script located on the web server. And form method = “post” as shown in the screenshot above.

Advertisement

Finally from the foregoing we have learnt that web forms need a CGI script for forms to work otherwise we may be left with an aesthetically well designed form but without functionality.

Keep Exploring

More from Tech

Filed under
Web development Internet
More topics
Intermediate tutorials
Advertisement