Nope, it didn't work...
doesn't matter, though, I can stress about that some other time.
Right now I have another small question..
I have this code:
my $user_ID = $form_parameters->param('username');
my $pass_word = $form_parameters->param('password');
# Send them back to the login if they left a field blank.
return $self->display_login() if $user_ID eq '';
return $self->display_login() if $pass_word eq '';
my $query = "SELECT USER_PASSWORD, USER_NAME FROM user WHERE USER_ID
= '$user_ID'";
my $sth = $dbh->prepare($query);
$sth->execute();
my ($passwd, $username) = $sth->fetchrow_array ();
$sth->finish();
# Validate the username..
unless ($session->param("logged_in"))
{
if (!defined $passwd)
{
return $self->display_login();
}
else
{
# Validate the username/password.
# if the password exists at all, the username
# is valid.. then make sure the password is correct.
# If not return to the login page.
unless ($passwd eq $pass_word)
{
return $self->display_login();
}
# Put some of the needed vars into the session.
$session->param('logged_in', 'yes');
$session->param('user_id', $user_ID);
$session->param('UserName', $username);
}
}
Now its the latter part of this that I am interested in..
unless ($passwd eq $pass_word)
{
return $self->display_login();
}
I return them to the login if they didn't get it right.. I'd like to be able
to pass them a message though..
for example. <font color='red'>Incorrect username or password</font>
If I want to pass that.. can I do this?
unless ($passwd eq $pass_word)
{
$self->param(Message => '<font color='red'>Incorrect username or
password</font>');
return $self->display_login();
}
Then pull it into the login sub and assign it a var
my $message = $self->param('Message');
Then add it to the vars I am passing to the template...
$login_page->param(message => $message);
Would that work, if so, is my syntax correct??? sorry to ask, but this
script is getting remarkably complicated for someone with my current skill
level, and I don't want to spend the next hour finding and removing the code
I added if I get it wrong..
If it does work that way... I can add stuff to tell the user their session
has expired and that they should login again as well....
again, any tips would be great....
I love CGI::Application and HTML::Template,, I will never write another cgi
app the old way.. (nested if/elsif/else/unless loops) THANKYOU!!!! to all
those that created these wonderful modules, and thankyou to all who help
teach newbies to them like me why they are so good.
regards
Franki
-----Original Message-----
From: William McKee [mailto:suppressed
Subject: Re: [cgiapp] cgiapp_prerun
Hi Franki,
Try setting a param in cgiapp_prerun using the following code:
$self->param('user_id', $user_id) ;
Then retrieve this value in your mode_1 sub with this code:
my $user_id = $self->param('user_id');
Good luck,
William
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.