#!/usr/bin/perl -w use DBI; use strict; # Create a new Apache request object my $r = shift; # Set up the parameter hash my %q = $r->method eq "GET" ? $r->args : $r->content; my $dbh = DBI->connect("DBI:mysql:adressen", "user", "secret", {RaiseError => 1}); $r->send_http_header; print qq( Adressbuch ); print qq(

Mein Adressbuch

Neuer Eintrag

Suche nach:

); for ('A' .. 'Z') { print "$_ \n"; } print "

\n"; if ($q{"list"}) { my $search = $q{list}; my $sth = $dbh->prepare("SELECT * FROM list WHERE nachname LIKE ? ORDER BY nachname"); $sth->execute("$search%"); my ($nachname, $vorname, $strasse, $plz, $ort, $telefon1, $telefon2, $email, $id); $sth->bind_columns(\($nachname, $vorname, $strasse, $plz, $ort, $telefon1, $telefon2, $email, $id)); if ($sth->rows > 0) { print "

"; print "

Gefundene Einträge:

"; print ""; print ""; while ($sth->fetch) { print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; } print "
NameStraßePLZ OrtTelefoneMail
$nachname $vorname$strasse$plz $ort$telefon1
"; print "$telefon2
$email"; print "Ändern  "; print "Löschen

\n"; } else { print "

Nichts gefunden.

\n"; } } print "
\n"; print qq( );