Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Login Script

by scorpio17 (Canon)
on Aug 28, 2012 at 21:03 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-03-28 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found