<?php
include("./include/config.inc.php");
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

if(!isset($_SESSION['s_activId']) && isset($_SESSION['s_activId']))

{

  header("Location:checkLogin.php");

}

else

{

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

 {

   $select = "SELECT userName,password,userType

                FROM user

				WHERE userName = '".mysql_real_escape_string($_POST['userName'])."'

                      AND password = '".mysql_real_escape_string($_POST['pwd'])."'";

   $selectRes = mysql_query($select);

   if($userLoginRow = mysql_fetch_array($selectRes))

   {

     $_SESSION['s_activId']  = $userLoginRow['userName'];

     $_SESSION['s_userType'] = $userLoginRow['userType'];

	 if(!isset($_SESSION['s_activId']))

	 {

	   header("Location:checkLogin.php");

	 }

	 else

	 {

	   header("Location:index.php");

	 }

   }

   else

   {

     echo "You Are Not Valid User";

   }

 }

}

 include("bottom.php");

 $smarty->display('checkLogin.tpl');

?>