This code ain`t pretty, but it works ....
(BTW, has been made possible only by the help of this mailing list, thanks again to everyone..)
Cheers, Sven
if ($action eq ''){ apply(); } elsif ($action eq "apply"){ my $count = find(); if ($count == 0) { error(); exit; } else { get_pw(); } }
# creates HTML from
sub apply {
# form w/ hidden field below
#<form action="../cgi-bin/passwd.cgi" method="post">
#<input type="hidden" name="action" value="apply">
}
# Checks if user exists in database
sub find {
my $dbh = DBI->connect($dsn, $db_user, $db_pass );
my $name = $q->param("f_name");
my $surname = $q->param("f_surname");
if ($surname =~ m/'/g) { ($surname) = grep s/'/\\'/g, $surname };
my $sth = $dbh->prepare(
"select count(*)
from .. where name = '$f_name' and surname = '$f_surname'" ) or mydie($DBI::errstr);
$sth->execute();
my ( $count ) = $sth->fetchrow_array();
$sth->finish;
$dbh->disconnect;
return $count;
}
# retrieves password from db
sub get_pw {
my $f_name = param('f_name');
my $f_surname = param('f_surname');
if ($f_surname =~ m/'/g) { ($f_surname) = grep s/'/\\'/g, $f_surname };
if ( ( $f_name ne '' ) and ( $f_surname ne '') ) {
chomp $f_name; chomp $f_surname;
my $dbh = DBI->connect( $dsn, $db_user, $db_pass ) || mydie($DBI::errstr);
my $sth = $dbh->prepare( "[select something] " );
$sth->execute() ;
}
On Sunday, June 1, 2003, at 10:39 PM, Annie wrote:
I have a form with two textfields ..one for login and one for password and two buttons reset and submit. on submit i need to verify the login and password from a table in mysql and want to retrieve the corresponding information of the verified id and password.
right now my perl code is able to retrieve all the fields of the table. i need to do the above...can anyone guide me.
--------------------------------- Do you Yahoo!? Free online calendar with sync to Outlook(TM).
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]