Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Login Script

by scorpio17 (Monsignor)
on Aug 28, 2012 at 21:03 UTC ( #990334=note: print w/ replies, xml ) Need Help??


in reply to Login Script

The code where you retrieve your form parameters should like something like this:

my $user_name = $cgi_object->param('user_name'} || ''; my $passwd = $cgi_object->param('passwd') || ''; unless ($user_name && $passwd) { # handle cgi param error }

The database query needs to use a placeholder, and check for errors - something like this:

eval { $sth = $dbh->prepare("select pass from users where user=?"); $sth->execute($user_name); }; if ($@) { # handle database error }

Since HTML is stateless, you need to use something like CGI::Session to remember that a particular user is logged in.

Using a framework will make your life much easier. Here's a link to a simple login tutorial I wrote:
RFC: Proposed tutorial - simple login script using CGI::Application

That should help get you started.


Comment on Re: Login Script
Select or Download Code
Re^2: Login Script
by ironside (Acolyte) on Aug 30, 2012 at 08:44 UTC
    That's a big help. Thank you.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990334]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-12-28 20:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (182 votes), past polls