<?
require_once "configure.php";

if(isset($_POST['btnSubmit'])) {
	
			$sql = "SELECT * from user WHERE  email='$email' and pwd='".md5($pwd)."' and approval='Yes' and block='No'";
			$result =mysql_query($sql)or die(mysql_error());
			if(mysql_num_rows($result)==0)print("<script type='text/javascript'>alert('Invalid email or password !!')</script>");	
			else{
				while($myrow=MySQL_fetch_array($result))
				{
					$_SESSION["egoUserID"]=$myrow["id"];
					$_SESSION["egoUserEmail"]=$myrow["email"];		
					$_SESSION["egoUserName"]=$myrow["name"];					
					$_SESSION["egoUserType"]=$myrow["type"];		
				}
				
			
				print("<script type='text/javascript'>location.href='index.php'</script>");

			}
	}
?>

<!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=utf-8" />
<title><?=TITLE;?></title>
<link rel="stylesheet" type="text/css" href="style.css" >
<script>
function ValidateForm(theform)
{
	var msg="";

	if(!theform.email.value)msg+="Email required. \n";
	if(!theform.pwd.value)msg+="Password required. \n";		
		
	if(msg){
		alert(msg)
		return false;
	}else return true;	
	
}
</script>
</head>

<body class="TextBox">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="46" bgcolor="#38abe3">
       <? require_once "header.php"; ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><form name="form" method="post" action="<?=$PHP_SELF;?>" ONSUBMIT="return ValidateForm(this)"><table width="60%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="35" class="signin">Sign In</td>
          </tr>
          <tr>
            <td height="30" bgcolor="#cfecff" class="text">Email </td>
          </tr>
          <tr>
            <td height="35" bgcolor="#cfecff" class="text"><input name="email" type="text" class="inputBox" id="email" value="<?=$email;?>" size="50" /></td>
          </tr>
          <tr>
            <td height="35" bgcolor="#cfecff" class="text">Password</td>
          </tr>
          <tr>
            <td height="35" bgcolor="#cfecff" class="text"><input name="pwd" type="password" class="inputBox" id="pwd" value="<?=$pwd?>" size="50" />
              <a href="forgot.php">Forgot password?</a></td>
          </tr>
          <tr>
            <td height="35" bgcolor="#cfecff" class="text"><input type="submit" name="btnSubmit" id="btnSubmit" value="Sign In" />
              <input type="button" name="button2" id="button2" value="Create  Account" onclick="javascript:location.href='register.php'"/></td>
          </tr>
        </table>
        </form></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><a href="http://egenos.com" target="_blank">Powered by eGen online solution</a></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>