HI dear members! I have a file called dbcon.pl into include directory.

#!/usr/local/bin/perl

use DBI;

# Database Username, Password and Driver settings
my $user="konsole";
my $pass="send";
my $host="localhost";
my $driver="mysql";
my $db="treat";
my $tnt="xyz";

# Connect Database
my $dsn = "DBI:$driver:database=$db;host=$host";
my $dbh = DBI->connect($dsn, $user, $pass);

Now I have created a another file login.pl there i include dbcon.pl using 
require.

--------------

#!/usr/local/bin/perl -w

require "include/dbcon.pl";

use warnings;
use CGI;
use CGI::Session;
my $cgi = new CGI;

my $login = $cgi->param('username');
my $passwd = $cgi->param('password');

print
        $cgi->header().
        $cgi->start_html(-title=>'My Login Page');

if($cgi->param("Submit"))
{
        my $sth = $dbh->prepare(qq{ select username, password from login where 
username=\'$login\' });
        $sth->execute();

        # Get the Result
        my ($username, $password) = $sth->fetchrow_array();
        $sth->finish();

       # checking valid user name
        if ($username eq $login and $password eq $passwd)
          {
                 print "Your User name and password accepted"
          }

        else { print "Wrong username or password"; }
}

$cgi->end_html;
exit(0);

-----------------------

but when i click on submit button its not working then I saw my apache errors 
logs there was a line.

Name "main::dbh" used only once: possible typo at /var/www/myinventory/login.pl 
line 19.
Can't call method "prepare" on an undefined value at 
/var/www/myinventory/login.pl line 19.

Please help me how i can solve this problem

Regards,

Umar Draz

 
---------------------------------
The fish are biting.
 Get more visitors on your site using Yahoo! Search Marketing.

Reply via email to