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
https://forums.phpfreaks.com/topic/184058-password-protect/
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
https://forums.phpfreaks.com/topic/184058-password-protect/#findComment-971744
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.