In Part 1 of the How to write Basic User Password authentication with PHP, we discussed what was required to create a web authentication interface. In today\'s installment we are going to give you what is required on the database front, with an explanation of what you are looking for.

I am sure everyone has seen the basics of a login form, and know what details you need you need to login, name a username and a password. However in my implementation I always have a unique user id, as an automatic incrementing integer field.The other two fields are self explanatory.

 

FieldNameField TypeField LengthNotes
useridint11An Auto Incrementing Primary Key
unamevarchar50a plain text field to be used for the username
upassvarchar50A plain text field to e used for the password

As you can see, this is a very simple table design, and the SQL below can be used to create it.

CREATE TABLE `user` ( `userid` int(11) unsigned NOT NULL auto_increment, `uname` varchar(50) NOT NULL, `upass` varchar(50) NOT NULL, PRIMARY KEY (`userid`) )

Once you have run this SQL in your database, you will have an empty table called user. In the next installment we will discuss how to add users.