#!/usr/bin/perl -Tw use strict; #use lib qw\/usr/dom/xbrie/brian/Hughes/perl\; ## set the path #$ENV{"PATH"} = "/usr/local/bin:/usr/ucb:/bin:/usr/bin"; use CGI qw(:standard); #use CGI::Carp; use DBI; my $dbh = DBI->connect("DBI:mysql:book","user", "password"); $|++; # Make the pipes piping hot! my $cgiquery = new CGI; my $myself = $cgiquery->self_url; print $cgiquery->header(-expires=>'now'); print $cgiquery->start_html(-"title"=>'Database funtionality', -"author"=>'brian@brie.com', -"meta"=>{'keywords'=>'brians database', 'copyright'=>'Copyright 1997 Big Brie'}, -"BGCOLOR"=>'white'); print qq{\n}; print "

Database Interface

\n"; print '

Developed by the man himself

Mr. Brian Lavender' , "\n"; # # Do we have a search submitted # my $keyword; if ($cgiquery->param('keyword')){ #assigns keyword to scalar $keyword = $cgiquery->param('keyword'); } $keyword =~ s/(.*)/\U$1/g; print "

"; # I moved search results up so I took out this link to it. #if ($keyword) { #Make a quick link to the results # print qq{See Results by scrolling down}; #} # Start the Form part of html for any and all forms on page. This must go before any form elements print $cgiquery->startform (-method=>'get'); # Search form of page print "

Search the Database

\n"; print qq{Will search the "approved data" table below
\n}; print "in name and city columns only\n"; print "

\n"; print "Search Keyword (10 characters max): ", $cgiquery->textfield(-name=>'keyword', -size=>10, -maxlength=>10); print " ",$cgiquery->submit(-name=>'add', -value=>'search'); print "\n"; print "

Database Server Status

\n"; # &dbase_run; # $dbh = Msql->connect; # $dbh -> selectdb("book"); # Results of search # only activated if a search was submitted. if ($keyword) { print '' , "\n"; print "

Search results

\n"; my $query = "SELECT * FROM customers WHERE cname LIKE '\%$keyword\%' or city LIKE '\%$keyword\%'"; my $sth = $dbh->prepare($query); if ($sth -> execute) { #if ($Msql::db_errstr) { # print "The select failed because $Msql::db_errstr
\n"; # $Msql::db_errstr = undef; # last; #} print "\n"; #Make this table a real table print "\n"; foreach (@{$sth->{NAME}}) { # print the Headers of the table print "\n"; } print "\n"; while (my @row = $sth->fetchrow()){ #Get each row from Msql object print "\n"; foreach (@row) { # print all the elements print "\n"; } print "\n"; } print "
", $_ , "
", $_ , "
\n"; } else { print "The query failed because
\n"; } } print "

Data Waiting for approval

\n"; print '
Follow this link'; print "

Submit data for review here

\n"; print " \n\n"; print "

\n"; # Get data for new insert print "Customer Number (xxxx): ", $cgiquery->textfield(-name=>'cnum', -size=>4, -maxlength=>4, -override=>1); print "
\n"; print "Customer Name (10 Char max): ", $cgiquery->textfield(-name=>'cname', -size=>12, -maxlength=>10, -override=>1); print "
\n"; print "City (10 Char max): ", $cgiquery->textfield(-name=>'city', -size=>12, -maxlength=>10, -override=>1); print "
\n"; print "Rating (xxx): ", $cgiquery->textfield(-name=>'rating', -size=>3, -maxlength=>3, -override=>1); print "
\n"; print "Salesman No (xxxx): ", $cgiquery->textfield(-name=>'snum', -size=>4, -maxlength=>4, -override=>1); print "

\n"; print $cgiquery->submit(-name=>'add', -value=>'Data Insert'); print $cgiquery->endform , "\n"; print "

\n"; #place all the values from the form into a scalar my $cnum= $cgiquery->param('cnum'); my $cname= $cgiquery->param('cname'); $cname =~ s/(.*)/\U$1/g; # Uppercase this thing my $city= $cgiquery->param('city'); $city =~ s/(.*)/\U$1/g; # I know I should use a subroutine my $rating= $cgiquery->param('rating'); my $snum= $cgiquery->param('snum'); if ( $cgiquery->param('cnum') && ($cgiquery->param('add') eq 'Data Insert') ){ # local ($Msql::QUIET) = 1; print "$cnum $cname $city $rating $snum

\n"; my $query = "insert into entries values ($cnum, '$cname','$city', $rating , $snum)"; my $sth = $dbh->prepare($query); if ($sth -> execute){ print "
It made it here
\n"; }else{ print "The insert failed
\n"; } } # This is the stuff in storage print qq{\n}; print "

This is all the "approved data" in Storage

\n"; print qq{TOP \n

\n}; my $query = "select * from customers"; my $sth = $dbh->prepare($query); $sth->execute; print "\n"; #Make this table a real table print "\n"; foreach (@{$sth->{NAME}}) { # print the Headers of the table print "\n"; } print "\n"; print "\n"; while (my @row = $sth->fetchrow()){ #Get each row from the Msql object print "\n"; foreach (@row) { # print all the elements print "\n"; } print "\n"; } print "
", $_ , "
", $_ , "
\n"; print q{


(C) 1997

Brie Web Publishing
PO Box 19184
Sacramento, CA 95819
(916) 443-6195

}; print $cgiquery->end_html, "\n"; # That is the end of it close (STDIN); close (STDERR); close (STDOUT); # Just in case these don't close automatically