<?php
session_start();
	require 'include/announcements.php'; // ITECHBIDS Configuration File
	require 'include/header.php';
	require 'include/left.php';
require 'include/itechbids.php'; // Server compatibility Patch
 $mode=$_POST['mode'];
$user=$_POST['txtUsername'];
$pass=$_POST['txtPassword'];
$url=$_POST['url'];
//exit();
if($mode=="check")
{
$url=$_GET['url'];
$productid=$_GET['productid'];
itechbidsdotcom($productid);
$sql="select user_name,password,last_login_date from member_details where user_name='$user' ";
$result=mysql_query($sql);
$tot=mysql_num_rows($result);
	if($tot == 0) 
{	
$msg=$err_77;
}	
    else
{	 
   
    $sql1="select user_name,password,user_id,last_login_date from member_details where user_name='$user' and password='$pass'";
    $result1=mysql_query($sql1);
	
	if (mysql_num_rows($result1) == 0) 
    {
$msg=$err_78;
    }
	else
{	
     $sql2="select user_name,password,user_id,last_login_date from member_details where user_name='$user' and password='$pass' and verified='yes' ";
	 $result2=mysql_query($sql2);
	 $chk=mysql_fetch_array($result2);
	 if (mysql_num_rows($result2) == 0) 
    {
$msg=$err_79;
    }
	else
{	

$sql3="select user_name,password,user_id,last_login_date from member_details where user_name='$user' and password='$pass' and payment_status='yes' ";
	 $result3=mysql_query($sql3);
	 $chk=mysql_fetch_array($result3);

	 if (mysql_num_rows($result3) == 0) 
    {
$msg=$err_90;
		
    }
else {
$sql4="select user_name,password,user_id,last_login_date from member_details where user_name='$user' and password='$pass' and approved='yes' ";
	 $result4=mysql_query($sql4);
	 $chk=mysql_fetch_array($result4);

	 if (mysql_num_rows($result4) == 0) 
    {
$msg=$err_91;
		
    }
else {
	 $date=date("Y-m-d");
     $login=$chk['last_login_date'];
    $log_up="update member_details set last_login_date='$date' where user_id=".$chk[user_id];
	 $upsql=mysql_query($log_up);
	 	 		if(isset($url))
{	
	$_SESSION[userid]=$chk[user_id];
	$_SESSION[username]=$chk[user_name];
	echo '<meta http-equiv="refresh" content="0;url='.$url.'?productid='.$productid.'">';
	echo "<font size=+1 color=#003366>Loading....</font>";
	exit();
}	
	else
	 {
    $_SESSION[userid]=$chk[user_id];
	$_SESSION[username]=$chk[user_name];
//	echo '<meta http-equiv="refresh" content="0;url=statistics.php?user_login='.$login.'">';
//     	echo "<font size=+1 color=#003366>Loading....</font>";
//	exit();
}}}}}}
?>
<?
if($msg!="")
{ 
?>
<table align=center><tr><td><b><font color="#FF0000"><? echo "$msg"; ?></font></b></td></tr></table>
<? 
}
}
?>
<!-- <TABLE cellSpacing=0 width=302 border=0 align="center">
  <TR><TD width="300">
 <form action="<? $_SERVER['PHP_SELF']?>" name=login method="post">
<table width="300" border="0" cellpadding="5" cellspacing="0" class="tablebox">
  <tr>
  <td colspan="2" valign="top"><b>Login</b></td>
    </tr>
  <tr>
    <td width="100" class="sidetext"><b>User Name</b></td>
    <td width="200"><input type="text" name="user_name" ></td>
  </tr>
  <tr>
    <td class="sidetext"><b>Password</b></td>
    <td><input type="password" name="password" ></td>
  </tr>
  <tr>
    <td><input type="hidden" value="check" name="mode">
	<input type="hidden" value=<?= $url;?> name="url"></td>
    <td><input type="submit" value="Sign In"> </td>
  </tr>
  <tr align="center"><td colspan="2"><a href="forgot.php">Forgot password</a></td></tr>
</table>
</form>

</TD></TR>
</TABLE> -->
					