<?php
@session_start();
@ob_start();
$conn = mysql_connect('localhost', 'root', '') or die ("connection not found");
	mysql_select_db('db_pustak') or die ("connection not found");
//include "header.php"; 
//$objIms->loginpage_alter();
	unset($_SESSION["uname"]);
	unset($_SESSION["pwd"]);
	
	if(isset($_POST["Save"])){
	
	//echo "SELECT * FROM system_login where emailid = '".$_POST["uname"]."' AND password = '".md5($_POST["pwd"])."'";
	 $query = mysql_query("SELECT * FROM system_login where emailid = '".$_POST["uname"]."' AND password = '".md5($_POST["pwd"])."'");
	
	if(mysql_num_rows($query)>0)
	
	{ $row = mysql_fetch_array($query) ;
		//die('hello');
		$_SESSION["uname"] = $row["emailid"];
		$_SESSION["pwd"] = $row["password"];
		
		$id=$row["id"];
		$_SESSION["id"]=$id;
		
		
		  $ip=$_SERVER['REMOTE_ADDR'];
		 //die($ip);
		  $lastlogin_date=date("d-m-Y");
		  date_default_timezone_set("Asia/Kolkata");
		  $last_time=date("H:i:s");
	mysql_query("update  system_login set lastlogin_date='".$lastlogin_date."',last_time='".$last_time."',ipaddress='".$ip."' where id=$id ");
			header("location:admin/index.php");
	//echo "<script>window.location.href='admin/index.php'</script>";
	}
	else
	{	
		
		echo "<span style='color:#fff'>Wrong ID or Password</span>";
		
	}		
}	
?>
<script type="text/javascript">
	$(document).ready(function() {                
				$("#FORMNAME1").validate({
                    rules: {
                   
					},
		messages: {
			
					slogin: "",
					spass:""
					 
								
				},
		  });                
            });
//---auto search-----
</script>


<style type="text/css">
body {
background-color: #f4f4f4;
color: #5a5656;
font-family: 'Open Sans', Arial, Helvetica, sans-serif;
font-size: 16px;
line-height: 1.5em;
}
a { text-decoration: none; }
h1 { font-size:20px; color:#FFF }
h1, p {
margin-bottom: 10px;
}
strong {
font-weight: bold;
}
.uppercase { text-transform: uppercase; }

/* ---------- LOGIN ---------- */
#login {
margin: 50px auto;
width: 300px; 
}
form fieldset input[type="text"], input[type="password"] {
background-color:#e5e5e5;
border:none; 
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
color: #5a5656;
font-family:'Open Sans', Arial, Helvetica, sans-serif;
font-size:14px;
height:50px;
outline:none;
padding:0px 10px;
width:295px;
-webkit-appearance:none;
}
form fieldset input[type="submit"] {
background-color:#008dde;
border:none;
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
color:#f4f4f4;
cursor:pointer;
font-family:'Open Sans', Arial, Helvetica, sans-serif;
height:50px;
text-transform:uppercase;
width:300px;
-webkit-appearance:none;
}
form fieldset a {
color:#5a5656;
font-size:10px;
}
form fieldset a:hover { text-decoration: underline; }
.btn-round {
background-color:#5a5656;
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
color:#f4f4f4;
display:block;
font-size:12px;
height:50px;
line-height:50px;
margin: 30px 125px;
text-align:center;
text-transform:uppercase;
width:50px;
}


#radial-center 
{ 
background-position: center center;
background-repeat: no-repeat;
background:-webkit-gradient(radial, center center, 0, center center, 460, from(#003B78), to(#011C38));
background:-webkit-radial-gradient(circle, #003B78, #011C38); 
background: -moz-radial-gradient(circle, #003B78, #011C38);
background: -ms-radial-gradient(circle, #003B78, #011C38); 
}

</style>
<script type="text/javascript"> 
 
		jQuery(document).ready(function(){
			$('#emp_name').autocomplete({source:'../ProgramFile/auto/TMS_suggest_EmpName.php', minLength:1,
			select: function (event, ui) {
        	$("#trn_atndnt_mas_id").val(ui.item.trn_atndnt_mas_id);
			$("#emp_name").val(ui.item.value); // display the selected text.
						
    }
			});
			
			
		}); 
	</script> 



<body id="radial-center">
<div id="login">
<h1><strong>Welcome to Login</strong> </h1>
<form method="post" id="FORMNAME1">

<fieldset style="border:#ccc solid 1px; background:#FFF">
<p><input type="text" required placeholder=" Username"  onBlur="if(this.value=='')this.value='Username'" onFocus="if(this.value=='Username')this.value='' " name="uname"></p>
<p><input type="password"  placeholder=" Password" name="pwd" required  onBlur="if(this.value=='')this.value='Password'" onFocus="if(this.value=='Password')this.value='' "></p>
<p><a href="#">Forgot Password?</a></p>
<p><input type="submit"  name="Save" value="login"></p>
</fieldset>
</form>

</div> <!-- end login -->



