Microsoft Word - Sam's Teach Yourself MySQL in 21 Days - SAMS.doc

(singke) #1






There are a number of text boxes inside the form. These boxes can take input from the user and pass it
to your CGI program. Notice that each box is given a name. This name will be passed to the server in a
name/value pair that you can parse and use.

Modifying the Database with Perl Script


Now take a look at a Perl Script that will take the data from this Web page and add it to your database.
Listing 14.3 adds vendor data to the database.
Listing 14.3 Perl Script for Adding Vendor Data


#!/usr/bin/perl


use DBI;


########################################Connect to the Meet_A_Geek database#
#######################################


$database = "Meet_A_Geek";


$driver ="mysql";


$dsn = "DBI:$driver:database=$database;$options";


$dbh = DBI->connect($dsn,"root",'tacobell')


or die "Error connecting to database";


%postInputs = readPostInput();

Free download pdf