<!-- Save Page as login.php -->
<?php
error_reporting(0);
include("config.php");
$username=$_POST['txtUsername'];
$password=base64_encode($_POST['txtPassword']); // Password is encrypted with base64_encode()
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login</title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
</head>
<?php
if(isset($_POST['btnLogin']) && ($_POST['btnLogin']=="Login"))
{
$strError=array(); // Array variable $strError is created to display error messages
if(empty($username))
{
$strError[] .="<li>Please Enter Valid Username</li>";
}
if(empty($password))
{
$strError[] .="<li>Please Enter Valid Password</li>";
}
$select = mysql_query("SELECT * FROM tbl_admin WHERE
username = '".$username."'
AND
password = '".$password."'"
);
$count = mysql_num_rows($select);
if($count > 0)
{
header('Location: welcome.php');
}
else if((!empty($username)) && (!empty($password)))
{
$strError[] .="<li>Invalid Username or Password</li>";
}
}
?>
<body>
<form name="frmLogin" id="frmLoginId" method="post" action="" target="" enctype="multipart/form-data">
<div id="login">
<div id="loginheading">Login
</div>
<div id="errormsg">
<?php
foreach($strError as $key => $val)
{
echo $val;
}
?>
</div>
<div id="logintitle">Username :
</div>
<div id="loginfield"><input type="text" name="txtUsername" id="txtUsernameId" value="<?php echo $username; ?>" size="20" />
</div>
<div id="logintitle">Password :
</div>
<div id="loginfield"><input type="password" name="txtPassword" id="txtPasswordId" value="" size="20" />
</div>
<div class="logincontent"><input type="checkbox" name="" value=""> Remember Me <a href="registration.php" style="margin-left:7px; text-decoration:none;"> Sign Up! </a><a href="" style="margin-left:7px; text-decoration:none;"> Forget Password? </a>
</div>
<div id="submitbtn"><input type="image" name="btnLogin" value="Login" border="0" src="images/login.png" width="70" height="30" />
</div>
</div>
</form>
</body>
</html>
Login Page
