<?php session_start();
include("connecting.php");

include("login_cookie.php");

$design = "d2";

//$db_login = mysql_query("SELECT * FROM `pytox_community`");

$password = mysql_real_escape_string($_POST['password']);
$username = mysql_real_escape_string($_POST['username']);
$username = htmlentities($username);

$db_login = mysql_query("SELECT * FROM `pytox_community` WHERE `bruger` = '{".$username."}' AND kode = '{".$password."}' LIMIT 1");

if ( mysql_num_rows($db_login) == 1)
{
	$login_user = mysql_fetch_assoc($db_login);
	if ($_POST["remember_settings"] == "on")
	{
		setcookie("user", $login_user["bruger"], time()+3600*24*14, 0, 0, 0);
		setcookie("pass", md5($login_user["kodeord"]), time()+3600*24*14, 0, 0, 0);
		setcookie("com", "1", 0, 0, 0, time()+3600*24*14);
		//setcookie("pass", md5($login_user["kodeord"]), time()+3600*24*14, "/", $_SERVER["HTTP_HOST"], 0);
	}
	else
	{
		newcookie("user", $login_user["bruger"]);
		newcookie("pass", md5($login_user["kodeord"]));
		newcookie("com", "1");
		$_SESSION[pycoins] = "yes";
		setcookie("inactive", "yes", time()+1200,"/", $_SERVER["HTTP_HOST"], 0);
		setcookie("timein", "yes", time()+3600, "/", $_SERVER["HTTP_HOST"], 0);
		setcookie("timer", time(), time()+36000000, "/", $_SERVER["HTTP_HOST"], 0);
		//$_SESSION["timer"] = date("H");
		$_SESSION["dage"] = date("d");
		$_SESSION["month"] = date("m");
		$_SESSION["year"] = date("Y");
		$_SESSION["time"] = time();
	}
	//print "Du er logget ind!";
	$locilocaitioniering = "Location: /pytox/designs/".$design."/index.php";
	header($locilocaitioniering);
	exit();
}
else
{
	$header3 = "Location: /pytox/designs/".$design."/index.php?message=failure&errorid=10348";
	header($header3);
	exit();
}

?>