Start the web server.
The following perl program may be used to access the mysql database.
Put the code in a file /var/www/cgi-bin/beatle.htm and test it by visiting
the page
http://host-1-19.linuxzoo.net/cgi-bin/beatle.htm
- but substitue
the actual address of your web server (you can find it from the "Server
Administration" page).
You will need to make this file executable.
The sample shown does not include the functionality to delete beatles.
You should do this yourself.
#!/usr/bin/perl
use strict;
use DBI;
use CGI qw(:standard);
import_names("Q");
print header;
my $dbh = DBI->connect("DBI:mysql:scott","scott","tiger")
|| print "Connection to mysql database failed: ". DBI->errstr;
print h1 "Beatles";
if ($Q::d){
print "You asked to delete: $Q::d";
}
my $sth = $dbh->prepare("select * from beatles")
|| print "The statement could not be prepared." . DBI->errstr;
$sth->execute
|| print "The statement could not be executed." . DBI->errstr;
while (my ($number,$name) = $sth->fetchrow_array){
print p "$number, $name " .
a({-href=>"?d=$number"},"Delete this Beatle");
}