Unstoppable Domains

Simple login system request

Spaceship Spaceship
Watch

comsit

New Member
Impact
0
i wanna know about simple login system in php , it seems so difficult for me , can anyone teach me ho?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Typical principles:

- Database (such as MySQL) to store usernames/passwords (preferably encrypted) and any other details you need to keep.
- Register page with fields that checks the data, if correct it adds it to the database, and forwards to the login page.
- Login page, to check login then set session data if correct, might also delete any current session data.
- Logout page, delete session data.
- Snippet to check whether the current username/password set in session data is valid. if(!$login->valid()) { header('login.php'); }

The best way to do this is typically OOP, there's lots and lots of classes available for login systems.

Dan
 
0
•••
Look up http://www.php.net/session_start and http://www.php.net/session_close to use sessions. Session variables ($_SESSION['variable_name']) are alive from the time you set them until they are unset or the session ends (browser window closes) or is closed manually.

As you gain more experience with logins and such, you'll learn how to make them secure and function better.

Also, passwords must be encrypted. Not doing so nowadays is pretty lame. Read up on PHP's md5() function, but be sure to salt your passwords with a secret 'salt phrase'. There's reasons for this. Google it to learn more, or ask me here for details...

Good luck
 
0
•••
  1. A user enters his user name and password in HTML form
  2. He hits the form submit button.
  3. The scripts checks his user name in database, whether it is correct or not.
  4. If it is not, you go back to 1st step :)
  5. If it is correct, the script creates a flag, stored in session. Usually, i store the user's id in session.
  6. The script redirects the user to welcome page.
    What if a user goes to the member-only URL directly before he is logged in?
    He should be redirected back to login page.
    Therefore, in your member-only page, you should check if the user has a flag in his session or not.
    If he has, do nothing, otherwise, redirects him back to login page.​
  7. -- Now for Logout --
  8. The script removes the flag (removes the flag session).
  9. Now, the user is marked as guest.
  10. The script redirects the user to index / login page. :)
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back