<?php



session_start();



include "connect.php";



if (isset($_POST['submit'])){



/*$agent= $_SERVER['HTTP_USER_AGENT'];



if (strlen(strstr($agent, 'Firefox')) > 0) {

*/





$email=mysql_real_escape_string($_POST['adminemail']);



$email=strip_tags($email);



$email=trim($email);



 



      $password=mysql_real_escape_string($_POST['password']);



      $password=strip_tags($password);



      $password=trim($password);



      $password=md5($password);







$getusername = "select * from admin where username='$email' and password='$password'"; 



      $result = mysql_query($getusername) or die(mysql_error());



      $result2=mysql_fetch_array($result);


//echo"$email & $password";


      if($result2)



{



@session_start();



$_SESSION['adminemail']=htmlspecialchars($email);



if(function_exists('date_default_timezone_set'))



date_default_timezone_set("Asia/Calcutta");



$lastonline=$result2['nowonline'];



      $nowonline=date("Y-m-d g:i:s a"); 



      $up="update admin set nowonline='$nowonline',lastonline='$lastonline' where username='$result2[username]'";

      mysql_query($up);


	  $mon=date("m");

	  if($mon>=04)
	  {
	  
	  $cy=date("Y");	  
	  $ny=$cy+1;
	  
	  $financial=$cy.'-'.$ny;
	  
	  }
	  
	  else
	  {
		  
	  $cy=date("Y");	  
	  $ny=$cy-1;
	  
	  $financial=$ny.'-'.$cy;
		  
	  }


	  $upd=mysql_query("insert into financial(user,financial) values('$result2[username]','$financial')");
	  
	  
if($result2['type']=='executive')
{
header("location:executive/index.php?s=1" . urlencode($Message));
}
else
{
header("location:index.php?s=1" . urlencode($Message));
}





      }



else







{ 


//echo"$email & $password";

header("location:login.php?s=2" . urlencode($Message));



}   



/*agent

}



else

{

header("location:login.php?s=3" . urlencode($Message));

}

*/



}



else



{



  // Not logged in



 echo '<META HTTP-EQUIV = "Refresh" Content = "1; URL =login.php">';



}



?>

