Thursday, September 24, 2009

Install a CGI Script in Website

You may have delayed cgi script installation due to the apparently complexprocess. Well, I avoided it also for several years, however if you want toincrease your web site's interactivity it's a necessity to know how to do it. It's not hard to learn and you don't have to be a programmer.
What is CGI ?
Common Gateway Interface or CGI is a program that can interact with an html form on your web site, and processes the results on your server usinga cgi script. The result generated is a dynamic web page. The cgi script iswritten in a language called PERL ("practical extraction and reportinglanguage").
Uses of CGI Scripts
CGI scripts are most commonly used for creating user interaction with an htmlform on your web site. Other uses include: autoresponders, shopping carts,counters, mailing list managers, ad management, surveys, polls, discussionboards, content management, calendars and click tracking. There are 100s of free cgi scripts that can be found on the Net. Just do a search on Google for "free cgi scripts" or visit the resources at the end of this article. We will create an html email form to collect the name, email address and comments of subscribers using a secure cgi formmail script. An automatic confirmation will be sent and the results of the email form will be passedon to your email address.
Steps to installing your own cgi script
. Check that your web host supports CGI - your web host will have a cgi-binfolder installed on the server. The cgi-bin is a special directory in the server where all the files which require security are kept. This is where you will upload your cgi script once it has been modified.
2. Download the cgi script - this is a secure cgi formmail script. Spammerscan't access and harvest your email address from this script.
3. Read the documentation that comes with the script - this will give you athorough understanding what changes you need to make to have it work correctly with your web site and server. It will also provide you with someexamples.
Editing your script
4. Open and edit your cgi script using notepad (don't use an html editor as thiscan create errors).
5. Remove the html tags from the script (at the top and bottom).
6. Change the path to perl to: #!/usr/bin/perl -wT (this is the first line of the script to be edited).
7. Edit the script - the bolded section of the cgi script shown below, are the other minimum fields to fill out in the script. Replace the fields in the script you downloaded with the bolded fields in the script below.

No comments: