Jump to content

Password protect


boldbaba

Recommended Posts

Hey everyone. I have a question. I have script that seems to have come from phpfreaks it is a members script. it allows people to set up a membership on there website. I have everything set up fine and it is all working. The problem i have is the password section. At the moment they have a register form and then they get an email with there encrypted password sent from phpmyadmin. They then login and go to the members section. But lets say my members section was called members.html when i go the browser and type in that url anyone can get in. How do i set it up that it is password protected page but allow the customer to use the password that they received from phpmyadmin. Thanks everyone for your help

 

John

Link to comment
Share on other sites

You would simply create a session, disallowing any use not logged in (within the session with the authenticated password you can pull from the database), than it will disallow access to members.php..

 

if ($_SESSION['loggedin'] == false) { 
   echo "You must first log in to view this page!";
} else { 
   echo "Welcome ".$_SESSION['username']." to the members area!"
}

 

Simple example, and you can set the session in login.php etc. redirecting to members.php.

 

IF you want it to remain HTML, than you'll need to write a long script to parse a .htpassword from that.. but that's more HTTP than php.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.