Table of Contents
Creating a login form in PHP is required in any normal PHP dynamic site. Following tutorial describe all the necessary steps to create login system in PHP site.
So there has not too much login in this page. All our login codes inside in our class.php file.It looks like below
From above
So , after successfully login in user will be redirected to profile.php file where we will show user's profile data like name,email,address,contact etc.
I hope this tutorial will help you understanding PHP Login system.In next tutorial i will write about my profile page
Section 1: Creating table of 'members' inside phpmyadmin
We need a database table for all members records,login system. 'members' table will have following fields
Below screenshot for 'members' table to be created in phpmyadmin section:2 Creating PHP login form
Here we have to create a login form using HTML and PHP.Find below code for this
in above code
It checks wheather user clicked submit button,after we get form field values of email and password.
Now here above we used PHP OOPS concept. We have created an object. access it's method i.e 'login'. Sent 2 parameters email and password.So there has not too much login in this page. All our login codes inside in our class.php file.It looks like below
From above
We have created a class 'user' and a method 'login'.Then defined a null array for array validation .
Here above we have checked whether user has left blank field for email and password. If user left blank, we store a message inside our 'error' array. Finally We have count no of value inside array.
Above we are checking whether count variable have some value or not. If count have value greater than '0' . It means there have some error. So we have shown error using foreach loop. In else part ,we have created a session 'mid' and stored user 'mid' value from database table.We have fetched user row details using $row=mysql_fetch_array($r);.So , after successfully login in user will be redirected to profile.php file where we will show user's profile data like name,email,address,contact etc.
I hope this tutorial will help you understanding PHP Login system.In next tutorial i will write about my profile page