do 'dbi-lib.pl'; use CGI ':standard'; use DBI; use strict; use vars qw($baseURL); # Declare base URL for return from this page $baseURL = "../index.html"; # print HTML header identifying document as HTML from dbi-lib.pl printHead('Logon User - Get Data'); print <TDPS
ENDOFTEXT createform(); printclose(); # # Gather data to create HTML form --------------------------------------- # sub createform { my $q = new CGI; # get values passed from form my $user = $q->param('user'); my $passwd = $q->param('passwd'); my $dbuser = 'ass2'; my $dbpasswd = 'tdps'; my $cnt; # Database DBI driver name my $dbname = "DBI:Oracle:"; # Create database handle my $dbh = DBI->connect($dbname, $dbuser, $dbpasswd); if (!$dbh) { showSQLerror("Connecting to the database"); return; } else { # set AutoCommit 1 = ON, 0 = OFF $dbh->{AutoCommit} = 1; } # Select to collect department numbers and names for pull down list # on form - **ONLY** use such lists if count of rows would be small # say 10 - 15 rows my $sql = "SELECT count(*) as cnt from users where USER_CODE = \'$user\' and PIN = \'$passwd\'"; # my $sql = "SELECT count(*) as cnt from users"; # Create a statement handle - prepare the statement my $sth = $dbh->prepare($sql); if (!$sth) { showSQLerror("Preparing SQL statement"); $dbh->disconnect; return; } # Execute the statement against the database $sth->execute; if ($DBI::errstr) { showSQLerror("Executing SQL Statment"); $sth->finish; $dbh->disconnect; return; } # Output the data fetched while (my ($cnt) = $sth->fetchrow) { if (my $cnt == 0) { print < Count0 $cnt ENDOFTEXT } else { print <$cnt ENDOFTEXT } print < ENDOFTEXT $sth->finish; $dbh->disconnect; }