You didn't ask about the password part specifically, although your subject hints at it.
If you want to verify the password, the previous resp are right on - you just might want to use
Digest::MD5 to build a one-way hash to store your password strings rather than plain-text strings. A lost password would need to get reset rather than recovered but this gives you a more reasonable level of security for a little bit of code. Have to use the same md5 function when building the user/password table.
use Digest::MD5 qw(md5);
# ... assume that $dbh was initialize previously ...
my $query = qq(SELECT count(*) FROM user WHERE username=? AND password
+=?);
my $sth = $dbh->prepare($query);
$sth->execute($user,md5($password));
($rc) = $sth->fetchrow_array;
if( $rc == 1 ) {
# user and pass matched
} else {
# user and pass did not match (rc == 0 ) or
# you don't have a unique key for user/pass (rc > 1)
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.