Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Login Script

by scorpio17 (Canon)
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.

Replies are listed 'Best First'.
Re^2: Login Script
by ironside (Acolyte) on Aug 30, 2012 at 08:44 UTC
    That's a big help. Thank you.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2019-10-24 00:48 GMT
Find Nodes?
    Voting Booth?