HTML Haven
  -- Basics
  -- Head/Body
  -- Font
  -- Links
  -- Images
  -- Tables
  -- Forms
  -- Attributes
  -- Wizards



CGI Haven
  -- Basics
  -- Variables
  -- Adding HTML
  -- Sending EMail
  -- Flat-File Databases
  -- Validation
  -- Regular Expressions
  -- Custom Script



JavaScript Haven
  -- Basics
  -- Variables
  -- Arrays
  -- Validation
  -- Functions
  -- Loops
  -- Conditionals
  -- Windows
  -- Events
  -- Forms
  -- Extras



CGI - Basics tutorial by Matt
This section will teach you the basics of
the perl language so you can begin scripting in CGI right away! First before we begin you
will need a few things.

1)Perl Interpreter
2)A Server that supports CGI
3)An Understanding of HTML

You can download the Perl interpreter from ActiveState
Choose the version that fits your system. You may need to download the
Windows Installer 2.0 if you don't already have it.

There are a lot of servers that support CGI but a lot of those servers must be paid for to use
but we have found two servers that support CGI and are free.

1)Tripod
2)Spaceports(Sending EMail Not Supported)

When you upload you CGI scripts you must always upload them in ASCII form rather then
Binary form. If you use WS_FTP LE or something like that to upload then you should
have that option along the bottom.

Now for your first CGI Script...

1)Start Notepad
2)Type in the code below
3)Save it as example.pl or example.cgi
4)Upload to your server
5)See how it runs

CODE: #!/usr/bin/perl use CGI; $query = new CGI; print $query->header; print "<html>\n<head>\n<title>Hello, World</title>\n</head>\n<body>\n"; print "Hello, World!\n"; print "</body>\n</html>\n";

---------------------------------------------------------------

EXPLANATION: Ok the first line of the script is the Shebang line, this line tells the server to open the
perl interpreter. Some servers have a different directory for the perl interpreter. The
Interpreter takes in each line of code and translates it into a language closer to what the
computer can read this is different from a compiled language such as C or C++. A compiled
language reads in the lines of code and creates a version that is closer to the computers
native language. The advantage of a compiled lanuage is it runs faster. You compile once
and run perl has to read through it everytime it is executed. The next line of the script
calls the CGI.pm module. The third line sets a variable for the newly created CGI.pm module.
Next we call the $query variable and we call the header function of the CGI.pm module.
This prints in the HTML document the content-type:text/plain or image/gif or othere that
are listed below figure 1.1. Next we use the print statement to print the beginning HTML
page. After that we print the text Hello World! to the browser window. Finally we
print the ending of the HTML page.

Figure 1.1 Content Types
text/plain
text/html
image/gif
image/jpeg

Tip: Most PERL/CGI Scripts are written in something
called subroutines which will help you organize you script. Subroutines are covered below.

Subroutines

Not all scripts should be written in subroutines and no script is required to be
written in subroutines. Subroutines will help you organize yourself better.
Say that you would like to send an email to the user, you could declare at the
top of the script something like &send_email;This
tells PERL to find in the script the declaration of send_email. You do not
have to name it send_email, it can be named anything you want. The
& sign tells PERL that this is a
subroutine. Subroutines will also allow you to execute the same section of
code multiple times without re-typeing it. You then would declare what this
subroutine would do later on in the script by using

sub send_email {
Put Other Code Here.
}


This is probably very confusing at first but maybe an example will help.

1)Open Notepad again.
2)Type in the code below.

#!/usr/bin/perl use CGI; $query = new CGI; &print_hello; sub print_hello { print $query->header; print "<html>\n<head>\n<title>Hello Example 2</title>\n"; print "</head>\n<body>\n"; print "Hello, World!"; print "</body>\n</html>\n"; } Now as you can see we start off the script as you just learned with the Shebang
line and we set a variable to the CGI.PM Module. Then we call the subroutine
&print_hello. PERL then calls this subroutine
and executes it. So this example will print the same output as the previous
example. This may still seem confusing but you will catch on eventually. That's
all there is to subroutines!

Before we move on we would like to remind you that you should know HTML before
trying CGI. If you don't know HTML yet HTML Haven
is a good place to learn it.

You should now have enough knowledge to move onto the next section Variables.




Scripting Network
  -- Register
  -- Login
  -- Contact
  -- Web Board
  -- Home



Fredward Inc.
  -- Websites
  -- Programs
  -- Graphics
  -- Order
  -- .::Other::.
  -- Contact
  -- Pricing
  -- Help/FAQ
 >>Official Site