Welcome to PhCyber Community

Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads

Cyber

Create User Login In PHP

Recommended Posts


PHP is a good alternative when you decide to add a password protected web pages on your web site. You can also use htaccess password protection but with PHP you can create a lot more complex and configurable protection. In this example I will use SESSION variables for login verification.

Lets start with building a configuration file for setting up all the username/password combinations. Create a new passwords.php file and add the following code in it.
 

For Established Members Only. Check this link for more info https://phcyber.com/topic/1703-phcyber-ranking/



Above code creates an $USER array with 3 username/password combinations. We also did a function which will be used later to check if an user is logged in or not. What we need now is a login page (called login.php) where users will enter their username and password and will login.
 

For Established Members Only. Check this link for more info https://phcyber.com/topic/1703-phcyber-ranking/



In order to use the user login feature for your PHP files you need to put that code at the very top of each of your PHP files that need to be protected.
 

For Established Members Only. Check this link for more info https://phcyber.com/topic/1703-phcyber-ranking/

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now