jayson Posted December 11, 2005 Posted December 11, 2005 I need a way to password protect a php file, I know thta I can password protect a directory, but nort what I want to do, my last site UI could do tghis Thanks Quote
TCH-Andy Posted December 11, 2005 Posted December 11, 2005 You can either, incorporate the password into the php script (so that it does start that script, but only completes it if you provide the correct password). Or You could edit the .htaccess file and add a password requirement in there for that file. Personally, I'd go for option 1. Quote
jayson Posted December 11, 2005 Author Posted December 11, 2005 You can either, incorporate the password into the php script (so that it does start that script, but only completes it if you provide the correct password). Or You could edit the .htaccess file and add a password requirement in there for that file. Personally, I'd go for option 1. I am just learning PHP, so not familar with either option Quote
TCH-Andy Posted December 11, 2005 Posted December 11, 2005 In that case, open your .htaccess file, and add >AuthName "Restricted Area" AuthType Basic AuthUserFile /home/myusername/.htpasswd AuthGroupFile /dev/null <Files protect1.php> require valid-user </Files> where myusername is your cpanel username and protect1.php is the file to be protected You will then need to create a file .htpasswd in your top directory >user:pass but the password will need to be encrypted. The easiest way may be to password protect a directory then get the encrypted password from the .htpasswd file. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.