|
Why CGIAlmost every one knows the great changes that the WWW technology brought to us after it came into the public domain, especially after the appearance of the graphical Web browsers such as Mosaic, and Netscape Navigator. Graphic Web browsers make it easier than ever before to retrieve internet resources. You can activate a hyperlink, download a file, or read a Usenet news article with a single mouse click. This is why WWW became more and more popular.
Now let's look at a simple static web page "staticPage.html", here is the HTML code: <html> <head ><title>Static page example</title></head> <center> <h1>Static Page Example</h1> </center> <p> This is an static web page example. Each time you request this page, the Web server will locate this page ( whose name is "staticPage.html") in the hard disk and send it directly back to the client. The exact same document is delivered with each request so you get the same content each time. <center> <a href="whycgi.html#static">Back </a> </center> </html> Click here to run the example to see the result. Each time you click, you get same information.
Now let's take a look at second example "textClock.shtml" which includes CGI script. This is a dynamic but not interactive CGI example. Here is the HTML code: <html> <head ><title>Non-Interactive CGI Example</title></head> <center> <h1>Non-Interactive CGI Example</h1> <p> This is an non-interactive CGI script example. It is a textclock. Each time you request this page, you will get the current date and time: <!--#exec cgi="cgi-bin/textclock.pl" --> <center> <a href="whycgi.html#dynamic">Back </a> </center> </html>
Let's see the third example, which is the famous "Hello, somebody!!" example. The following is the "hello.html": <html> <head ><title>Interactive CGI Example</title></head> <center> <h1>Interactive CGI Example</h1> </center> <p> This is an interactive CGI program, which is the well-known "hello, somebody!" program. Enter your name and click the submit button, see what will happen! <p> <form method=POST action="cgi-bin/hello.pl"> <pre> Your Name: <INPUT NAME="name" TYPE="TEXT" SIZE="20" MAXLENGTH="30"> <INPUT TYPE="SUBMIT" VALUE="Send"> <INPUT TYPE="RESET"> </PRE> <center><a href="whycgi.html#interactive">Back </a></center> </html>Click here to Run the example. Take a look at the above three example, you can easily tell the difference between them. Actually, CGI works in many places where many of us may not have beenaware of it. Have you ever used a powerful search engine such as Yahoo, Infoseek or Excite ? That is where CGI are working. However, while the uses of CGI can be quite powerful and far-reaching, it is not as difficult to code as one might expect. We will see some simple examples of CGI scripting as we continue with this workshop. |