<?php
session_start();
require_once('config/config.php');
require_once(CLASS_DIR.'dbClass.php');
$obj = new DBClass();


if(isset($_REQUEST['email']) && ($_REQUEST['email'] != '')) {
	$sql = "SELECT * FROM ".TBL_USER." WHERE email = '".$_REQUEST['email']."' AND password = '".$_REQUEST['password']."'";
	$rs = $obj->executeQry($sql,$link);		
	$row = $obj->fetchrow();
	if($obj->getRow() > 0) {
		$exp_date = $row['exp_date'];
		$currentdate = date("Y-m-d");
		if($exp_date > $currentdate){
			if($row['aprove'] == 0){
				$_SESSION['memberID'] = $row['id'];
				$_SESSION['profileID'] = $row['profileID'];
				$_SESSION['email'] = $row['email'];
				$_SESSION['fname'] = $row['fname'];
				$_SESSION['lname'] = $row['lname'];
				setcookie("memberID", $row['id'], time()+3600);
				setcookie("email", $row['email'], time()+3600);
				setcookie("fname", $row['fname'], time()+3600);
				setcookie("lname", $row['lname'], time()+3600);
				header("location:http://coalmandi.com/".$_REQUEST['rurl']);
				exit;
			}
		}
	}
	header("location:http://coalmandi.com/".$_REQUEST['rurl']);
	exit;
}

?>