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

include("login_cookie.php");

$design = "d2";

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

$replace["username"] = str_replace("Ø", "&Oslash;", $_POST["username"]);
$replace["username"] = str_replace("ø", "&oslash;", $replace["username"]);
$replace["username"] = str_replace("Å", "&Aring;", $replace["username"]);
$replace["username"] = str_replace("å", "&aring;", $replace["username"]);
$replace["username"] = str_replace("Æ", "&Aelig;", $replace["username"]);
$replace["username"] = str_replace("æ", "&aelig;", $replace["username"]);

$db_login = mysql_query("SELECT * FROM `pytox_community` WHERE `bruger` LIKE '{$replace[username]}' LIMIT 1");

if ( mysql_num_rows($db_login) != 0 ) {

while($login_user = mysql_fetch_assoc($db_login)) {

if ($login_user[exist] == "1") {

if ($_POST["password"] == $login_user["kode"]) {

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);
} else {
$header1 = "Location: /pytox/designs/".$design."/index.php?message=failure&errorid=54578";
header($header1);
}

} else {
$header2 = "Location: /pytox/designs/".$design."/index.php?message=failure&errorid=60065";
header($header2);

}

} // lukker while

} else {
$header3 = "Location: /pytox/designs/".$design."/index.php?message=failure&errorid=10348";
header($header3);
}
?>