First of all create a database and Run this sql query in Phpmyadmin then follow next steps...
CREATE TABLE IF NOT EXISTS `members` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`sign_up_date` datetime NOT NULL,
`email` varchar(255) NOT NULL,
`bio` text,
`account_permissions` enum('a','b','c') DEFAULT NULL,
`email_activation` enum('0','1') DEFAULT NULL,
`password` varchar(255) NOT NULL,
`lastlogin` datetime DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Now Make your web pages as....
....................................................................................
-------------------For SignUp---------------------
save this as 'signup.php'
<h3 align='center'>Signup for a New Account</h3>
<h4 align='center'>Please fill given details below:</h4>
<form id='regForm' name='regForm' method='post' action='registerit.php'>
<table width='600' border='0' cellpadding='2' cellspacing='0' align='center'>
<tr>
<th>*Email </th>
<td><input name='email' type='text' class='textfield' id='email' /></td>
</tr>
<tr>
<th>*Username</th>
<td><input name='username' type='text' class='textfield' id='username' /></td>
</tr>
<tr>
<th>*Password</th>
<td><input name='password' type='password' class='textfield' id='password' /></td>
</tr>
<tr>
<th>*Confirm Password </th>
<td><input name='cpassword' type='password' class='textfield' id='cpassword' /></td>
</tr>
<tr>
<td> </td>
<td><input type='submit' name='Register' value='Register' /></td>
</tr>
</table>
</form>
------------------------------------------------------------------------
Save this as registerit.php
<?php
define('DB_HOST', 'localhost');
define('DB_USER', 'YOUR_DATABASE_USERNAME'); //Change Username with Your
define('DB_PASSWORD', 'YOUR_DB_PASSWORD'); //Change Password with Your
define('DB_DATABASE', 'YOUR_DB_NAME'); //Change Database name with Your
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_DATABASE);
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
$cpassword = $_POST['cpassword'];
$date=date('Y-m-d h-i-s A');
if($password==$cpassword)
{
$q = mysql_query("insert into members (email,username,password,sign_up_date) values('$email','$username','$password','$date')");
if ($q)
{
echo "<h2>Registration Successfull</h2>
<a href='index.php'> Click to Login</a>";
}
else
{
echo "Something wrong with Query";
}
}
else
{
echo "<h3>Password Not Match</h3>
}
?>
---------------------------------------------------------------------------------
-------------------For Login---------------------
Save this as 'index.php'
<h3 align='center'>Login</h3>
<form id='loginForm' name='loginForm' method='post' action='loginit.php'>
<table width='600' border='0' cellpadding='2' cellspacing='0' align='center'>
<tr>
<th>*Username</th>
<td><input name='username' type='text' class='textfield' id='username' /></td>
</tr>
<tr>
<th>*Password</th>
<td><input name='password' type='password' class='textfield' id='password' /></td>
</tr>
<tr>
<td> </td>
<td><input type='submit' name='Login' value='Login' /></td>
</tr>
</table>
</form>
--------------------------------------------------
Save this as loginit.php
<?php
define('DB_HOST', 'localhost');
define('DB_USER', 'YOUR_DATABASE_USERNAME'); //Change Username with Your
define('DB_PASSWORD', 'YOUR_DB_PASSWORD'); //Change Password with Your
define('DB_DATABASE', 'YOUR_DB_NAME'); //Change Database name with Your
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_DATABASE);
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
$sql = mysql_query("SELECT * FROM members where username='$username' && password='$password'");
if(mysql_num_rows($sql)==1)
{
session_regenerate_id();
$member = mysql_fetch_assoc($sql);
$_SESSION['SESS_MEMBER_ID'] = $member['id'];
$_SESSION['SESS_EMAIL'] = $member['email'];
$_SESSION['SESS_USERNAME'] = $member['username'];
session_write_close();
header("location: logged.php");
}else {
echo "Username Password Not Matched";
}
?>
-----------------------------------------------------------------------------------------
Save this as 'logged.php'
<?php
//Start session
session_start();
if($_SESSION['SESS_USERNAME'] == '') {
header("location: access-denied.php");
exit();
}
else
{
echo "Welcome $_SESSION[SESS_USERNAME] You are Logged in";
echo "<br /><a href='logout.php'>Logout</a>";
}
?>
---------------------------------------------------------
Save it as 'logout.php'
<?php
//Start session
session_start();
unset($_SESSION['SESS_MEMBER_ID']);
unset($_SESSION['SESS_EMAIL']);
unset($_SESSION['SESS_USERNAME']);
//Unset the variables stored in session
echo "<h1>Logout </h1>
<p align='center'> </p>
<h4 align='center' class='err'>You have been logged out.</h4>";
?>
-----------------------------------------------------------
Save it as 'access-denied.php'
<?php
echo "<h3>Access Denied</h3>";
?>
-------------------------------------------------------------------------------------
I think that this will solve your problem... enjoy...