what's the problem you're having? also, i would suggest using CGI.pm as it will make the forms and mundane html easier.

Update: Apache::Htpasswd is sweet! I had been writing htpasswd the old caveman way.. with crypt. This module makes things very nice.. oh and here's a little something that uses Apache::Htpasswd and CGI

#!/usr/bin/perl -wT use CGI qw(standard); use CGI::Carp qw(fatalsToBrowser); use Apache::Htpasswd; my $htpasswd="htpasswd"; my $main=new CGI(); print $main->header; print $main->start_html('Password Administration'); $main->import_names('Q'); if ($Q::form) { if (($Q::username) && ($Q::oldpass) && ($Q::newpass)) { # all the forms have been entered &change_pass } else { print "please fill in all fields"; } } else { # must be a first time customer print $main->startform; print "<table border=0 cellpadding=1 cellspacing=0>\n"; print "<tr><td>Username: </td><td>",$main->textfield(-name=>'u +sername',-size=>30),"</td></tr>"; print "<tr><td>Password: </td><td>",$main->password_field(-nam +e=>'oldpass',-size=>30),"</td></tr>"; print "<tr><td>New Password: </td><td>",$main->password_field( +-name=>'newpass',-size=>30),"</td></tr>"; print "<tr><td>&nbsp;</td><td>",$main->submit(-name=>'form',-v +alue=>'Change Password'),"</td></tr></tab le>"; } sub change_pass { if (-e $htpasswd) { # if the htpasswd file exists my $htpass = new Apache::Htpasswd("$htpasswd"); # use Apache::Htpasswd's builtin function to verify old pass befor +e changing $htpass->htpasswd($Q::username,$Q::newpass,$Q::oldpass +); # get errors (if any) my $err=$htpass->error; if ($err) { print "Error. Most likely due to an inccorect +password or username \n"; } else { ## must be no errors print "user $Q::username password changed\n"; } } else { print "$htpasswd cannot be found\n"; } }

-p


In reply to Re: Apache::Htpasswd syntax questions by thatguy
in thread Apache::Htpasswd syntax questions by c

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.