When you are going to create login, you should follow the following steps
Technology : PHP
Database MYSQL
Server : WAMP
1. Create the user table
CREATE TABLE `Users` ( `user_id` int(4) NOT NULL auto_increment, `username` varchar(65) NOT NULL default '', `userpassword` varchar(65) NOT NULL default '', PRIMARY KEY (`user_id`) ) TYPE=MyISAM AUTO_INCREMENT=1 ;
Insert user login information into table
INSERT INTO users VALUES (1, 'john', '1234');
2. Create the login page like mylogin.php
<form id="form1" name="form1" method="post" action="my_login_action.php">
<table border="0" width="95%" cellpadding="0" align="center" cellspacing="0" >
<!--DWLayoutTable-->
<tr>
<td colspan="4" height="25" align="left"> </td>
</tr>
<tr>
<td width="68"></td>
<td height="35" width="173" align="right" valign="middle">My e-mail address is:</td>
<td width="7"></td>
<td width="441" align="left" valign="middle"><input name="login_email" type="text" id="login_email" maxlength="50" />
</td>
</tr>
<tr>
<td ></td>
<td height="35" align="right" valign="middle">My password is:</td>
<td ></td>
<td align="left" ><input name="login_password" type="password" id="login_password" maxlength="50" />
</span></span></td>
</tr>
<tr>
<td height="45" colspan="4" align="right" valign="middle"><label>
<input name="Login" src="images/log-in-button.gif" type="image" id="Login" value="Login" />
</label>
</td>
</tr>
</table>
</form>
3. Create the login action file as my_login_action.php
if($_REQUEST['Login'])
{
extract($_REQUEST);
$_check_login = "Select * from Users where username = '$login_email' && userpassword = '$login_password'";
$_check_login_01 = mysql_query($_check_login) or die(mysql_error());
if(mysql_num_rows($_check_login_01) > 0)
{
header("Location: successlogin.php");
exit();
}
else
{
header("Location: failurelogin.php");
exit();
}
}
4. Create the login success page as successlogin.php
<?php
// Check if session is registred or not. If not redirected to main page of the php
// paste this code on the first line in the page of php
session_start();
if(!session_is_registered(successusername)){
header("location:main_success_login.php");
}
?>
<html>
<body>
my php page Successfully logged in
</body>
</html>
</body>
</html>
5. Create the login failure page page as failurelogin.php
<?php
// if login failed, page redirected to the main login page
// paste this code on the first line in the login page of php
session_start();
if(!session_is_registered(successusername)){
header("location:main_login_page.php");
}
?>
<html>
<body>
you are mentioned user name or password is wrong
</body>
</html>
</body>
</html>
6. Create the Logout page page as logoff.php
// Paste this code on the top off the logoff.php page.
<?php
session_start();
session_destroy();
Tags: php, Mysql, php login page, php mysql page, login page, email using php login, login using php, logout pge, logoff, create database, login success, login failure, login success php, login failure,php