i think it's pretty self-explanitory, but here goes:
you can either have two pages to do this, or one page with functions that you create. at any rate..
1st page or function:
displays the "form" containing the fields that are required for the user to log in, they fill these out and click the button.
2nd page or function:
grabs $username and $password and compares it to the appropriate line in your .htaccess. for example, open the file, get the line the info is on, store it in a variable, explode that variable and compare it with your $username and $password variables.
i think. i'm brain farting, sorry.