blaze has asked for the wisdom of the Perl Monks concerning the following question:
i dont know for sure if that helps or not, i was thinking that the uninitialized error might mean something about the problem im having, now if i put in the correct username and password, it prints the loan amount, just like i want it to, the only time i have a problem is if i put a valid username and invalid password..well here's my code:[Fri Aug 16 21:49:25 2002] [error] [client 12 +7.0.0.1] [Fri Aug 16 21:49:25 2002] amysloan.cgi: Data +base handle destroyed without explicit disconnect., referer: http://l +ocalhost/cgi-bin/amysloan.cgi [Fri Aug 16 21:49:31 2002] [error] [client 12 +7.0.0.1] [Fri Aug 16 21:49:31 2002] amysloan.cgi: Use +of uninitialized value in string ne at C:/Program Files/Apache Group/ +Apache2/cgi-bin/amysloan.cgi line 32., referer: http://localhost/cgi- +bin/amysloan.cgi
#!/Perl/bin/perl -w use Digest::MD5 qw/md5_base64/; use CGI::Carp qw/fatalsToBrowser/; use CGI qw/:standard/; use DBI; use strict; print "Content-type:text/html\n\n"; my %info; my $driver = "mysql"; my $database = "amy"; my $dsn = "DBI:$driver:database=$database;host=localhost"; my $dbh = DBI->connect($dsn) or die "Couldnt connect: $DBI::errstr\n"; my $username = param('username'); my $password = md5_base64(param('password')) if param('password'); if(!$username){ relogin("Enter your username"); }elsif(!$password){ relogin("Enter your password"); } my $sth = $dbh->prepare("SELECT * FROM info WHERE pword='$password'"); $sth->execute() or die "Couldnt do it: $!\n"; while(my $ref = $sth->fetchrow_hashref){ %info = %{$ref}; } $sth->finish(); $dbh->disconnect(); if($username ne $info{'uname'}){ relogin("Invalid Username"); } if($password ne $info{'pword'}){ relogin("Invalid Password"); } print $info{'loan'}; sub relogin{ my $msg = shift; print <<HtmlCode; <html> <head> <title>Login</title> </head> <body> <center> <form action="/cgi-bin/amysloan.cgi" method="post"> <table border="0"> <tr> <td colspan="2"><center>$msg</center></td> </tr> <tr> <td>Login:</td> <td><input name="username" size="10" value="$username"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" size="10"></td> </tr> <tr> <td colspan="2"><center><input type="submit" value="login"></center> +</td> </tr> </table> </form> </center> </body> </html> HtmlCode exit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Accessing information pulled from mysql
by grep (Monsignor) on Aug 17, 2002 at 05:16 UTC | |
by blaze (Friar) on Aug 17, 2002 at 19:42 UTC | |
by grep (Monsignor) on Aug 17, 2002 at 23:05 UTC | |
by blaze (Friar) on Aug 19, 2002 at 07:45 UTC |