I'm trying to allow users to login to my script via an html form (Fields:username,password).

The database is a flatfile, and looks like this:

user1|cryptedpass1

This will be the only line in this password file as it's for the admin section.

Here is the code that I'm using to validate:

open(PASSWD, "$adminpasswddir/adminpasswd.db") || &dienice("Can't +open the file adminpasswd.db $!"); $admin_passwd = <PASSWD>; close(PASSWD); chop($admin_passwd); ($ausername,$apasswd) = split(/\|/,$admin_passwd); $test_passwd = crypt("$FORM{'password'}","k3"); if ($test_passwd eq "$apasswd" && $FORM{'username'} eq "$ausername +"){ &admin_main; } else { &dienice("Your username/password combination is incorrect. Ple +ase press your browsers back button and try again."); }

The problem that I'm having is that when I try to login, it says my password is incorrect. I noticed when putting some of the variables into the error page that when the script writes the password to the db it writes it as "k3LFRiJg/OOe" and when the script creates a variable with the entered admin password to be used to verify the password it creates a string which is identical with the addition of "Q" at the end "k3LFRiJg/OOeQ".
I know I'm not very advanced, but I just can't figure this one out I used the same line of code to create the password, so there should be no reason why this isn't working.

Thanks for all your continued support,
Titanic_Fanatic


In reply to username/password validation by titanic_fanataic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.