<?php
session_start();
include('config.php');
if(isset($_POST['sub'])) {	
	$username=$_POST['username'];
	$pw=md5($_POST['pwd']);
	$query = "SELECT * FROM `tbladmin` WHERE `username`='".$username."' AND `password`='".$pw."'";
	$result = mysql_query($query);
	$rows = mysql_num_rows($result);
	
	if ($rows > '0') {		
		$row=mysql_fetch_array($result);
		$_SESSION['username'] 	= $_POST['username'];
		$_SESSION['id']			= $row['id'];
		header('location: lenders.php');
		die;
	}	
	else 
	{	
		echo "<script language='javascript'>alert('Username OR Password is wrong')</script>";
		echo "<script>window.location='index.php';</script>";
				
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <title>Admin</title>
	<script src="js/gen_validatorv4.js" type="text/javascript"></script>
	<link href="css/style.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
  <div class="MainContainer">
    	<div class="Header">
        	<div class="Logo"><img width="223px" height="60px" src="http://fintrack.com.au/loancal/tcpdf/examples/images/fint-logo.jpg" alt="logo"></img></div>
        </div>
        
        <div class="AdminLogin">
        	<div class="Heading">Administration</div>
			<form method="post" name="login_form" id="login_form" >
            <table cellpadding="0" cellspacing="0" border="0" class="LoginArea">
            	<tr>
                	<td align="right">Username :</td>
                    <td><input type="text" name="username" id="username" /></td>
                </tr>
                <tr>
                	<td align="right">Password :</td>
                    <td><input type="password" name="pwd" id="pwd" /></td>
                </tr>
            </table>
            <div class="Border"></div>
            <div class="GoButton"><input type="submit" name="sub" value="submit"  /></div>
			</form>
        </div>
        
        
        
        <div class="Footer"><a href="javascript:;">Site.com</a>. All rights reserved.</div>
        
    </div>
	
	<script  type="text/javascript">
		var frmvalidator = new Validator("login_form");
		frmvalidator.addValidation("username","req","Please enter username.");
		frmvalidator.addValidation("pwd","req","Please enter Password.");
	</script>
  </body>
</html>