<?
	/*
	** File: LOGIN_USER
	** Description: verify user and create a session
	** Version: 1.0
	** Created: 03/24/99
	** Author: Leon Atkinson
	** Email: leon@clearink.com
	*/

	
	//include module for getting a User ID based on login/password
	include("$Application_Root/modules/include/getUserID");


	//filter input variables
	$inputLogin = substr(trim($inputLogin), 0, 255);
	$inputPassword = substr(trim($inputPassword), 0, 255);


	/* 
	** if we are submitting a username and password, make sid
	*/
	if(($inputLogin != "") && ($inputPassword != ""))
	{

		$user_ID = getUserID($inputLogin, $inputPassword);

		if($user_ID > 0)
		{
			$Query = "UPDATE session ";
			$Query .= "SET User=$user_ID "; 
			$Query .= "WHERE ID='$sid'";
			mysql_query($Query, $DatabaseLink);
			
			$UserInfo = GetUserInfo($user_ID);
			$ActionResults = "You are now logged in!";

			if(USE_AUTOLOGIN)
			{
				//set cookie for login/password
				setcookie("cookie_al", $inputLogin, time()+AUTOLOGIN_LIFETIME);
				setcookie("cookie_ap", md5($inputPassword), time()+AUTOLOGIN_LIFETIME);
			}

		}
		else
		{
			$ActionResults = "Login Failed!";
			$SCREEN = "login";
		}
		
	}
	else
	{
		$ActionResults = "You must supply a username and password!";
		$SCREEN = "login";
	}

?>
