Alex Rivera | Logout

Login/Registration System with php and mysql

Asked 2010-10-25T00:03:49.577
9

I would like to make a simple user login/registration system using PHP and mysql. I don't need to get any information beyond what is necessary for the user to log in and out. I want to make sure that the system is secure.

The way that I currently understand how it should work is:

Registration

User enters their email address and password and confirmation password.

The PHP script makes sure the passwords match and that the email is a valid address and is not already in the database.

It hashes the password along with a random salt and stores the salt and resulting hashed password in the database. (Is php's md5 function suitable for this? I am not quite sure how this part works.)

Store an email confirmation code in the database and send the given email address a link back to the website that contains that code for verification?

Login

User input their email address and password.

The server looks up the email in the database and retrieves the salt. Then hashes the salt with the password the user just provided to see if it matches the one in the database.

How do I make the session persist after login. With a PHP session? A cookie? What should get stored in the cookie for remembering the user between visits?

I basically would just like some verification that the process I am describing is an accurate and secure way of doing user registration/login. Also, what are some good tutorials with more information.

Edit
Report

1 Answer

1

Since Login systems are such an integral part of a website, you're screwed if it gets hacked. Unless you're doing this for educational purposes, I recommend finding a system that was created by someone that has experience in the field. You'll sleep soundly at night.

An example of a solid pre-built login system is tank auth, it's written for the Code Igniter framework. You might want to look at how this guy designed the system to get ideas on what's important if you decide to write your own.

Also just a note from experience, it takes more time to write a login system from scratch than it does to learn the code igniter framework and install tank auth.

answered 2010-10-25T00:44:32.657

Your Answer