1,105,417 Community Members

need help password protecting a directory

Member Avatar
webdi
Newbie Poster
16 posts since Jul 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,

I've not been successful looking for a solution to my problem.

What I need is to password protect a directory. I could use htaccess, but the user doesn't want a pop-up login window. He wants to start on a page with a form with the username and password fields. Once the proper login credentials are entered, then access is granted to everything in the protected directory.

Can anyone link me to instructions on how to do this?

Thanks much for your help!

Member Avatar
diafol
Where are my eyes?
12,986 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,849 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 
session_start();
if(!isset($_SESSION['passok']))header("Location:pass.php");

at head of files in this folder. pass page gets input - if ok set session variable.

Member Avatar
webdi
Newbie Poster
16 posts since Jul 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks much.

So then, on my login page how do I set the passok?

Member Avatar
diafol
Where are my eyes?
12,986 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,849 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 

your pw form sends data to a form handler page which sets the session variable then redirect to the default page in the protected folder if pass matches the expected pw. if no match redirect to the pw form again with an error msg.

Member Avatar
Stefano Mtangoo
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 441 [?]
Q&As Helped to Solve: 394 [?]
Skill Endorsements: 2 [?]
 
0
 

Hi,

I've not been successful looking for a solution to my problem.

What I need is to password protect a directory. I could use htaccess, but the user doesn't want a pop-up login window. He wants to start on a page with a form with the username and password fields. Once the proper login credentials are entered, then access is granted to everything in the protected directory.

Can anyone link me to instructions on how to do this?

Thanks much for your help!

http://www.devarticles.com/c/a/PHP/PHP-for-Beginners-by-a-Beginners/
http://www.sitepoint.com/anthology-2-1-access-control/
http://www.sitepoint.com/forums/php-34/php-login-redirect-logout-script-732382.html

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: