|
| |
CGI ScriptWhat is a CGI script?A CGI script is like a program. It is a collection of lines of code that contain instructions for a computer. Programs, however are compiled so that they will run faster on a particular OS. CGI scripts are just simple text files that are interpreted as needed. CGI scripts are smaller and simpler than programs. CGI scripts can be written in Perl, PHP, C, Visual Basic, Python or whatever. Perl and PHP seem to be the languages of choice. That's because they are easy to learn and are very portable. Not all Perl scripts are CGI scripts. Only Perl Scripts that follow CGI protocol are CGI scripts. Sample Perl/CGI ScriptThe CGI script written in Perl has a very simple structure. The CGI script shown below would print the words Hello World to the PC screen. The shebang line tells the browser where to find the Perl interpreter on the server. The content header tells the browser what kind of content to expect. #!perl #shebang lineprint "Content-type:text/html\n\n"; #Content Headerprint <<End_of_Doc;<html><head><title></title></head><body>Hello World </body></html>End_of_Doc
|
Web Hosting Services Directories Contact |
Sample PHP ScriptTo do the same thing with PHP the code is:
<html><head></head>
PHP/MySQLPHP is especially useful when working with relational databases and MySQL. For information on this subject, visit our PHP/MySQL Tutorial. CGI Scripts and HTML FormsOne common use of a CGI script is to process the data collected on an HTML Form. A form contains input devices. Text boxes, textareas, check boxes, radio buttons and selection boxes are all examples of these input devices. The name of the the processing CGI script is placed in the action attribute of the form structure. The browser accesses the CGI script when the Submit button on the form is pressed. Free HTML Form Template KitYou can download our free form template kit. The kit includes a form for receiving personal information from a user and 2 CGI scripts for processing the data. There is an actual active demo of the HTML form on the page so you can try it out. |
![]() |
| Net Success 2000 Plus Inc PO Box 1508 Somerset, KY 42502 Copyright 2000 - 2006 Net Success 2000 Plus Inc Last Modified: August 11, 2006 |