<?php
session_start();
include ('incip.php');
if($_SERVER['REQUEST_METHOD'] == "POST") {
    //mysql_connect("connection.php", "username", "password");
    //@mysql_select_db("database") or die( "Unable to connect to database");
    $email = mysql_real_escape_string($_POST['email']);
    $password = mysql_real_escape_string($_POST['password']);
	$LOGIN_TYPE = mysql_real_escape_string($_POST['LOGIN_TYPE']);
    $query = "SELECT * FROM contact_person WHERE email ='$email' AND password='$password' AND login_type = '$LOGIN_TYPE'";
	//echo $query;
	$result = mysql_query($query,$conn);
    if(mysql_num_rows($result) > 0) {
      $_SESSION['is_logged_in'] = 1;
	  $LOGIN_NAME = $_POST['email'];
	  $EMPLOYEE_PASSWORD = $_POST['password'];
	  $LOGIN_TYPE = $_POST['LOGIN_TYPE'];
	   while($row=mysql_fetch_array($result)){ $id = $row['id']; }
	  $_SESSION["LOGIN_NAME"] = $LOGIN_NAME;
	  $_SESSION["EMPLOYEE_PASSWORD"] = $EMPLOYEE_PASSWORD;
	  $_SESSION["LOGIN_TYPE"] = $LOGIN_TYPE;
	  $_SESSION["userid"] = $id;
	
    }
  }
//exit();
  if(!isset($_SESSION['is_logged_in'])) {
header("location:login.php");
}
else {
    header("location:index.php");
  }
?>







