473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Login page perl/CGI

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
sa************@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 <<BodyHTML;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html lang="en" xml:lang="en" xmlns=" http://www.w3.org/1999/xhtml">
<head>
<title>Registration Form</title>
</head>

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

my $dbh = DBI->connect("DBI:mysql:database:localhost","its","roo t",
{ 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 <a href =
"passreset.cgi">password reset</apage to reset your password.)); }
}
else { &dienice(qq(Username does not exist. Go to the <a href = "
custreg.cgi">registration</apage to register.)); }
$dbh->disconnect;
print end_html;

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

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

Apr 27 '07 #1
0 6443

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ghazan Haider | last post by:
I am posting this for the lack of a better newsgroup, and for the knowledge of people here, and because its only partially OT. We have a bunch of users with their computers at work. There are...
4
by: dschruth | last post by:
Hello. Can anybody solve this problem? I am using a server-side language (PERL) to *try* to POST data to a HTTPS login script that doesn't have a standard "submit" button. The form appears...
1
by: james2 | last post by:
I am trying to write a perl script that will do remote machine. I have done user loging using simple command; $telnet->login('test', 'test123'); But now I want to do root login or superuser...
6
by: joe t. | last post by:
The subject may sound a little cryptic, so i'll try my best to explain. Details are unavailable, as i am under a nondisclosure agreement, but i'm looking for general principles and tips, not...
3
by: Hari Sekhon | last post by:
Hi everyone, I want to create a test that will do a proper login test to a web site but I need some pointers. I need to login to the website by accessing an https url and posting to that,...
3
by: focussys | last post by:
hi i am a student and am doing this for one of my assignments i am trying to create a login using perl and mysql database.i was succesful in doing that now i want to use cookies for...
4
by: Freedolen | last post by:
Hi All, I had a perl script which is used to login in a web page, but it gives the error as "301 Moved Permanently". What does this means and how can it be rectified? Can anyone help on this? ...
6
by: sherrygomindes | last post by:
Hi I have written a perl script using the Telnet module. I need to remotely login in from one windows XP machine to another XP machine. But i get errors which i can't figure out the reason....
12
by: tvnaidu | last post by:
I have Two kinds of web pagess, one is for control page for only admin login, another one is to view status for user login. initially both html files can view with 192.168.0.10/control.htm and other...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.