MySQL Forums
Forum List  »  Perl

validating username and password in db???
Posted by: Naveen Gupta
Date: April 29, 2005 06:41AM

i've been able to establish mysql connectivity to display all the data in in an html page by invoking a perl script in the web server. But tough things ahead. I've been trying uselessly for hours to create a script which takes username and password from the user and validate them with those in mysql table and return a response in either situation but not being able to do it.
my script looks somewhat like----


use CGI;
use DBI;
my $query = new CGI;
print $query->header();
#print $query->start_html(-title=>'LOGIN PAGE');


if(($query->request_method() eq "POST") && ($query->param("user") ne '') && ($query->param("password") ne ''))

$dbh = DBI->connect("DBI:mysql:database=$db:host=$host", $user, $password) or die "Can't connect to database:$DBI::errstr\n";
$qry = $dbh->prepare("SELECT emp_name, password FROM table where emp_name=$user");

if ($user eq $name && $password eq $pass)
print "

Thank You!

print $query->end_html();
print "<HEAD> Username or Password Incorrect!</HEAD>";
print "Please Try Again";

print $query->end_html();
#print "Content-type: text/html\n\n";

#print <<EOF;
print "<HTML>";
print "<BODY>";

print "

print "<input type='text' name='user'>

print "

print "<input type='password' name='password'>
print "<input type='submit' value='submit'>
print "</FORM>";
print "</BODY>";
print "</HTML>";
#print $query->end_html();

not getting the desired output. basically a problem of data validation with db.
Could anyone help me out with this one!!
Thanks a lot

Options: ReplyQuote

Written By
validating username and password in db???
April 29, 2005 06:41AM
May 02, 2005 01:16AM
May 02, 2005 02:19AM
May 02, 2005 04:08AM
May 02, 2005 06:08AM
May 02, 2005 06:19AM
May 02, 2005 06:36AM
May 02, 2005 07:25AM
May 02, 2005 11:49PM
May 03, 2005 03:58PM
May 04, 2005 04:55AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.