The Checkout Script

In Hour 16, I didn’t write code to do anything with the order information the user entered after the checkout form was processed. In this hour, I’m inserting the order data into the database, so you can see how the back-end processing often works for online stores. As you’ve probably guessed, I had to make the same changes to this script that I had to make to the other scripts in order to get them to talk to the database. Before I look at the script’s new functionality, let’s look at the source code, which appears in Listing 20.5.

Listing 20.5. The Source Code to checkout.pl
 1: #!/usr/local/bin/perl 2: 3: use strict; 4: 5: use CGI; 6: use CGI::Carp qw(fatalsToBrowser); 7: use DBI; 8: 9: my $query = new CGI; 10: 11: my $database ...

Get Sams Teach Yourself CGI in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.