I Made a Form. What Do I Do Now?
We receive that type of question occasionally. Every time, it reminds me of my own first steps into forms and CGI.
The first form I made didn't work. When I clicked the button, nothing happened. No matter how long I waited for something to happen, it just sat there, doing nothing.
That's when I began learning about CGI.
I had just started using the Internet and, to accelerate my learning, I had accepted a job at an ISP.
Because I had years of programming experience at that time, I acquired a workable understanding of CGI rather quickly. I can imagine that it must be rather tough going for those who have no related experience.
Hopefully I can explain it clear enough so even folks new to the Internet can comprehend the main points without a lot of effort.
Let's try it.
A browser displays web pages. Some of those web pages have forms to fill in.
When the information is filled in, the form is submitted. Submission is usually accomplished by clicking a button. However, the button might be substituted with an image.
Whether button or image, the information is submitted.
Submitted to what?
You'll understand more about CGI when that question is completely answered.
When a form is submitted, the information in the form is sent somewhere -- not to the browser; it's sent somewhere else.
So, where does the information go?
It can go to any one of several different places, but all of the destinations do something with the information received.
The information might be sent to your email program. These types of forms exist, but are in the minority.
Usually, when the information is submitted from forms, it is sent to a computer program on a server.
A server is a computer that your browser contacts in order to get a web page.
When the form is submitted, the information is sent to a program on a server for handling. The program can do any of various things with the information submitted to it, whatever fulfills the purpose of the form.
The form might be a feedback form, a "recommend this website" form, a form to search the website or the Internet, a survey or a quiz, a merchandise order form, an ebook download form. a subscription form, well you get the idea.
Whatever type of form is its, the thing to learn from this article is that when a form is submitted, the information is sent somewhere. Usually, it is sent to a program on a server which handles the information according to the purpose of the form.
The purpose of a form often, though not always, requires that the submitted information be stored in a database of some type, maybe a log of activities, and/or sent in an email to a certain location.
(When you decide you want forms, select the type of program that will handle the information submitted to it in the manner you desire. See the Master Series of CGI programs here for ideas.)
And that's about it, except for one more thing.
When a form is submitted to a program on a server, the browser waits for an acknowledgment. That acknowledgment is usually in the form of a "thank you" page. But it might also be a succinct message such as "info received."
Something must be returned to the browser after the browser submits form information to a program on the server. It's a requirement of CGI and the browser expects it.
CGI can be used for ever so much more than just for handling information submitted with forms. But that's beyond the scope of this article.
A fun article about how CGI works is "How CGI Works."
That page also contains links to other articles that may be of interest and of benefit in further study.
Will Bontrager