Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

nisc wwwxxx, wwwxxx0cm, should producers of software-based services, such as atms, be held liable for economic injuries suffered when their systems fail?, wwwxxx0cm,, Event 9 IIS log failed to write entry, wwwxxx jeffs, Catastrophic failure Unexpected method call sequence. 0x8000ffff (-2147418113)., ksh lock a file, [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_DBC failed



#1: Login page perl/CGI

Posted on 2007-04-27 07:53:03 by Sandy

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

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

use CGI qw(:standard);
use CGI::Carp qw(warning's fatalsToBrowser);
use strict;
use DBI;

print "Content-type: text/html\n\n";
print <<BodyHTML;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// ">
<html lang="en" xml:lang="en" xmlns="">
<title>Registration Form</title>

<form name = "login" action = "logincheck.cgi " method = "POST">
User Name
(25 characters or less)
(8 - 15 alphanumeric characters)
<td><input type = "text" name = "UserName" id = "UserName" size = "25"
maxlength = "25" tabindex = "0" />
<td><input type = "text" name = "Password" id = "Password" size = "15"
maxlength = "15" tabindex = "1" />
<input type = "submit" value = "Login" tabindex = "2" />
<p>To register go to the <a href = "register.cgi">registration</a>
print end_html;

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

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
$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 <a href =
"passreset.cgi">password reset</a> page to reset your password.)); }
else { &dienice(qq(Username does not exist. Go to the <a href = "
custreg.cgi">registration</a> page to register.)); }
print end_html;

sub dienice {
my ($msg) = @_;
print "<h1>$msg</h1>";

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

Report this message