<?php
// Leiratkozás a hírlevélről
include('config.php');
include('language/messages.'.$default_lang.'.php');
function connect_mysql() 
{
	global $host, $username, $password, $db;
	$connect = mysql_connect($host,$username,$password);
	mysql_select_db($db);
	mysql_query("set names latin2");
}
connect_mysql();

if ($_GET['id'] != "" && $_GET['code'] != "")
{
	$code = mysql_escape_string($_GET['code']);
	$id = mysql_escape_string($_GET['id']);	
	$update_query = "UPDATE users SET status=0, cancel_date=NOW() WHERE usr_code='".$code."' AND usr_id='".$id."'";
	mysql_query($update_query);	
	if (mysql_affected_rows() == 0)
	{
		header("Location: $goto?cancel=failed");	
		echo $msg['cancel_failed'];
	}
	else
	{
		header("Location: $goto?cancel=succesful");
		echo $msg['cancel_succ'];
	}
}
else
{
	header("Location: $goto2");
}

?>