#!/usr/bin/perl -Tw # # db consult # # Here you can add "use strict" and make the environment safer. Check the # guestbook.cgi script in LinuxFocus article 203 from November 2001 issue. # This is especially true if you allow the user to write into the database table. use DBI; use CGI qw(param()); print < LFAuthors main db


Search by author


Author name :
END_of_start if (param("author") ne '') { $author = param("author"); $autsrch.='"'; $autsrch.=$author; $autsrch.='"'; # username has to be replaced with an user name who has read permissions # to the database table. Careful here, since this script doesn't ask for any # authentication. If you want the user to write into the table, you MUST ask for # login and password. $dbh = DBI->connect("DBI:mysql:lf","username",''); $sth = $dbh->prepare(" select * from trissue where author = $autsrch "); $sth->execute; # Display result print <
END_suite while( ($num,$category,$title,$author,$en,$es,$fr,$de,$nl,$ru,$tk,$issue)=$sth->fetchrow() ) { print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; } print "
Num Category Title Author En Es Fr De Nl Ru Tk Issue
$num $category $title $author $en $es $fr $de $nl $ru $tk $issue
"; print "
"; print "
"; print "
"; } else { # DB Connect $dbh = DBI->connect("DBI:mysql:lf","username",''); # Search $sth = $dbh->prepare(" select * from trissue "); $sth->execute; # Display result print <
SUITE while( ($num,$category,$title,$author,$en,$es,$fr,$de,$nl,$ru,$tk,$issue)=$sth->fetchrow() ) { print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; } print "
Num Category Title Author En Es Fr De Nl Ru Tk Issue
$num $category $title $author $en $es $fr $de $nl $ru $tk $issue
"; print "
"; } print end_html; $sth->finish; # Disconnect $dbh->disconnect; exit;