Hi! I have a script and i want to change the user's password! All the passwords are in a text file written like this:username=passowrd on each line! In my script i want the user to write his username, old password, new password and confirm new password! When he does this to change the password in the text file! I have the following code but it doesn't change the password in the file
#!/agl/tools/perl/bin/perl use strict; use CGI ':standard'; my $I_username = param('username'); my $I_psswd = param('password'); my $I_newpsswd = param('new_password'); my $I_cnewpsswd = param('cnew_password'); my $data_file = '/data/aww/cgi-bin/login.txt'; open(DAT, "+>>$data_file") || die("Could not open file: $!"); my %password; while (<DAT>) { chomp; my ($k, $v) = split /\=/; $password{$k} = $v; if (($I_username eq $k) and ($password{$I_username} eq $I_ps +swd) and ($I_newpsswd eq $I_cnewpsswd)){ print DAT "$I_username=$I_newpsswd \n"; print "<h2>OK</h2>"; } else { if($I_newpsswd ne $I_cnewpsswd){print " +<center><h2>Noua parola nu se potriveste !</h2></center>\n";} else {if($I_username ne $k){ print "<center><h2>Utilizatorul + nu exista!</h2></center>\n";} else {if($password{$I_username} ne $I_psswd){ print "<center +><h2>Ai introdus parola veche gresit!</h2></center>";} } }}} close(DAT);
Thank you very much for your time!

In reply to changing password by bory

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.