<?require ("global.php");?>
<?php

if (isset($_POST['username']) && isset($_POST['password']))
{
  $query = "SELECT ID FROM users WHERE username = '" 
    . $_POST['username'] . "' AND password = password('"
    . $_POST['password'] . "') LIMIT 1";
  $result = mysql_query($query, $db);
  if ($result)
    {
      if ($r = mysql_fetch_array($result))
	{
	  setcookie("userID", $r['ID']);
	  header("Location: /tick/events.php");
	}
      else { header("Location: /tick/login.html"); }
    }
  else { header("Location: /tick/login.html"); }
}
else { header("Location: /tick/login.html"); }

?>
