Current location: Hot Scripts Forums » Programming Languages » PHP » Password Protected Pages


Password Protected Pages

Reply
  #1 (permalink)  
Old 12-22-03, 08:34 AM
Alan Alan is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Password Protected Pages

Hi.

I'm still relatively new to PHP and could use some help.

I'd like to write one PHP file which can only be viewed once a valid password has been entered, but I'm unsure of how to do so.

If someone could point me in the right direction, I would be very grateful.

Thanks.
Reply With Quote
  #2 (permalink)  
Old 12-22-03, 11:42 AM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Good morning,

It depends on several things, but there are more than one way to do it.

If there is (and will be) only one page, the page does not get reloaded often, and if you are still new to PHP, then you might as well authenticate the users every time the page is loaded, rather than using sessions and databases.

I am not going to list an entire code because I'm not sure whether you want that. But my tip is to use a file that contains password and is located outside the document root (for added security). Every time the page is loaded, check if the login info has been submitted by the user. If not, show the login form. If so, authenticate his/her password by matching it with the file that contains passwords. Only when there is a match, will you let him/her login.

Again, this is one very simple solution. You can go deeper, depending on how you want/need it.

Hope this gives you some idea. Good luck.
__________________
Blavv =|
Reply With Quote
  #3 (permalink)  
Old 12-22-03, 12:00 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
i know of a very ez code but it would only require 1 password. but im guessing you want more than 1 which can be hard. jheres a link to how to make 1:

http://phpfreaks.com/tutorials/40/0.php it will also contain a zip file of what the tutorial covers

hopes this helps
Reply With Quote
  #4 (permalink)  
Old 12-22-03, 08:25 PM
Alan Alan is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you for your tips.

As my PHP skills improve I will go further, but for now all I wanted was to try and get just one page protected by a password.

Your tips have helped and I think I know how I'm going to do this now.

Thanks a lot.

Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SEO Expert Available nakulgoyal Job Offers & Assistance 2 08-14-04 12:38 PM
password textbox mpriest HTML/XHTML/XML 14 07-07-04 09:56 AM
How to convert php generated pages to SE friendly HTML or PHP(SE friendly) -CLASS 101 crippled PHP 1 11-16-03 06:37 AM
acessing password protected folder perleo PHP 1 09-26-03 08:36 PM
carry logging state across pages superman PHP 1 06-30-03 09:55 AM


All times are GMT -5. The time now is 07:42 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.