Example 3.1 is the script from Chapter 8. The script is provided mostly so that you can see how Shopping Bag works from end to end. The script works fine, but it is primitive. If you want a powerful shopping program with numerous server-side options, I suggest you seek a more robust solution.
Remember that shoppers provide sensitive credit card information in the order form. If that information isn’t properly protected before it is submitted, it can easily get into the wrong hands and be used illegally. To prevent this, your web server host should support some type of protection such as Secure Sockets Layer (SSL), a protocol used for encryption. Most web server hosts support it. You should contact your web site administrator and find more information about SSL at http://webopedia.internet.com/TERM/S/SSL.html.
bag.pl has three jobs:
Get all the product and customer information
Save that information in a uniquely named text file on the web server
Print a confirmation page to send back to the browser
Some web server hosts require that you run CGI scripts with a
.cgi extension instead of a
.pl extension. No biggie—just rename the
bag.cgi. Quick recovery.
Let’s see how bag.pl takes care of all three jobs. As you look at this code, remember that you don’t have to understand the syntax. This book isn’t about Perl. Just try to follow what the code is doing from one step to the next.
Example C-1. bag.pl
1 #!/usr/bin/perl 2 3 require "cgi-lib.pl"; ...