Is CGI easy? Of course it IS for users who know it well. Is this also true for users who are not good at programming? Ohh?! Some readers with not so much expereince on programming may be shocked by the table of contents even before they seriously begin to work on it and give up. Their reason sound perfect. They don't know the annoying PERL and C, and most important, they even don't want to learn them. Can these people set up their own CGI application? The answer is YES. When I first set up my own CGI applications (one of them is textclock, another is Formail), I was so exciting to see how great they were working. But unforunatly in that time I even didn't know how to program with PERL and what CGI really was. But anyway, they run perfect and they were made by myself! That's made me happy.
Most commonly, the CGI users are not programmers. They are just the common people. They include CGI in their homepages just to add some useful features or just make their web page cool. It's not neccessary for them to know every details of CGI and programming. They can easily take other people's work and benefit themself.
In fact, there are lots of web sites which maintain free CGI scripts that you can free download by yourself. Usually these sites also provide the README file to help you set up your own application. What you need to do is just download the script to your server (modify some parameter is necessary),follow the README file step to step. It will work!
Of all the sites that provide free CGI scripts, probabaly the Matt's Script Archive is the best one. In this site, there are many useful CGI scripts such as Guestbook, Formail,etc written in several programming languages such as PERL and C. We thanks Matt Wright for his great effort to provide us with so powerful and useful CGI scripts. In our lecture we will use Matt's Script Archive 's PERL scripts as examples.
Note the following examples are directly downloaded from Matt's Script Archive, not like the prevoius lectures where the example codes are written by myself.
Let's see how to do that:
chmod 755 textclock.pl
<a href="http://bau.cba.uh.edu/CGITutorial/textclock.pl"> Get Textclock Time</a>
Here are the steps:
chmod 755 countdown.pl
<html><head><title>Countdown Examples</title></head> <body><h3>Want to know how long till the year 2000?</h3> <a href="http://your.domain/cgi-bin/countdown.pl?2000,1,2,0,0,0">Countdown to the year 2000!</a> <p> <hr> <p> Or make your own date!!! <form method=GET action="http://your.domain/cgi-bin/mattw/countdown.pl"> <input type=text name=""> (Format: yyyy,mm,dd,hh,mm,ss) <p> <input type=submit> </form><p> <hr> <p> <a href="http://your.domain/cgi-bin/countdown.pl">Get the default countdown!</a> <p> <hr> <p> <h3>Ignore the # of seconds in countdown to 2000</h3> <a href="http://your.domain/cgi-bin/countdown.pl?2000,1,2,0,0,XX">Countdown to the year 2000!</a> </body></html>Change the above red URL to whatever your countdown.pl locate, here it is:
http://bau.cba.uh.edu/CGITutorial/countdown.pl
Let's see how to do that:
@referers = ('worldwidemart.com','206.31.72.203');This should change to your machine's Domain name and IP address. This statement is there mainly for security reason.It prevents the user from other machine to use your scripts.The machine I am working with is "bau.cba.uh.edu",which is the server of CBA of UH, its IP address is "129.7.14.7". So I change to the following :
@referers = ('bau.cba.uh.edu','129.7.14.7');
chmod 755 FormMail.pl
<html> <head><title>FormMail</title></head> <center><h1>FormMail</h1> <form method=POST action="http://bau.cba.uh.edu/CGITutorial/FormMail.pl"> <INPUT TYPE=HIDDEN NAME="recipient" VALUE="zyu@bau.cba.uh.edu"> <INPUT TYPE=HIDDEN NAME="subject" VALUE="WEB feedbook"> <PRE> Your Name: <INPUT NAME="realname" TYPE="TEXT" SIZE="20" MAXLENGTH="30"> E-mail address: <INPUT NAME="email" TYPE="TEXT" SIZE="20" MAXLENGTH="30"> Feel free to send your comment... <TEXTAREA NAME="comments" ROWS="4" COLS="30"> </TEXTAREA> <INPUT TYPE="SUBMIT" VALUE="Send"> <INPUT TYPE="RESET"> </PRE> </form> </html>Note that the zyu@bau.cba.uh.edu is the email address where you want people to send you this message.