Login page perl/CGI

Login page perl/CGI

am 27.04.2007 07:53:03 von Sandy

hello,,,,,,,,,
i am creating login page using Perl/CGI facing prob... able to
connect DB but from there facing prob
If u have related code of login page in Perl please send me on
sandip.bhosale@gmail.com

please help me


i am using MySQL as DB user name:root password:root database name:ITS

and Table is User_login,
Column 1: User_Name
Column 2: User_Pass

--
#!c:/perl/bin/perl.exe
use CGI qw(:standard);
use CGI::Carp qw(warning's fatalsToBrowser);
use strict;
use DBI;


print "Content-type: text/html\n\n";
print < www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">


Registration Form



















User Name
(25 characters or less)

Password
(8 - 15 alphanumeric characters)
maxlength = "25" tabindex = "0" />
maxlength = "15" tabindex = "1" />



To register go to the
page.




BodyHTML
print end_html;

my $dbh = DBI->connect("DBI:mysql:database:localhost","its","root",
{ RaiseError => 1,
AutoCommit => 1 }) or &dienice("Can't connect to database:
$DBI::errstr");

my $UserName=param('UserName');
my $Password=param('Password');
my $sth = $dbh->prepare("select * from User_Login where User_Name
= ?") or &dbdie;
$sth->execute($UserName) or &dbdie;
if (my $name = $sth->fetchrow_hashref)
{
my $sth = $dbh->prepare("select * from user_Login where root = ?") or
&dbdie;
$sth->execute($Password) or &dbdie;
if (my $pass = $sth->fetchrow_hashref)
{
print redirect(- location=>"index.cgi");
}
else { &dienice(qq(The password is invalid. Go to the "passreset.cgi">password reset page to reset your password.)); }
}
else { &dienice(qq(Username does not exist. Go to the registration page to register.)); }
$dbh->disconnect;
print end_html;

sub dienice {
my ($msg) = @_;
print "

$msg

";
exit;
}

sub dbdie {
my ($errmsg) = "$DBI::errstr
";
&dienice($errmsg);
}
Sandip B Bhosale.