For my website, I'm trying to create a login form where visitors can type in their login/password, and have PHP check that login with HTTP Authentication (.htaccess). So instead of user typing in the direct URL and entering their user/password in the pop up box, they could simply do it from a form. I was wondering if this was possible and if so how? In case you're wondering, I want to do this for conviences and design purposes. Thank you!

This speaks of very poor design. It would make sense to use PHP to modify/maintain .htaccess files, but it doesn't make sense to use .htaccess files as a storage place for PHP user logins. If you like the concept of using a file, rather than a database, to store username/password combos, why don't you just put a plain-text file outside of the web-accessible directory structure and authenticate off of that?

Now if you are talking about using PHP to grant HTTP Authentication using the .htaccess file and bypassing the typical login pop-up, that is another question altogether. I don't think it is possible, but I will look. I still think it would be better design to stay away from the HTTP Authentication model completely if you don't really want to use it.

You might want to read this PHP-Based User Authentication guide for beginners for some ideas.

hi vartotojas,

well from my own project, what i did was i had a table in the database that consists of all the username and passwords(encrypted form) after which, i created a login form using html with username and password boxes. Then i create a php script that will capture the username and password entered and compared it with the table i had created in the database that consists of the members' names and passwords. If match, the user can log in, if not it will not be allowed to log in.
Furthermore, u can read up more on php sessions. Hope it helps :)


This article has been dead for over six months. Start a new discussion instead.