<?

include_once "./setting.php";
include_once $global["root"] . "/include/handle.php";
include_once $global["root"] . "/include/print_array.php";

include_once $global["root"] . "/lib/Site.php";

$Site = new Site;
$Site->init("mail");

// escape error.
if (! $_POST["name"] or trim($_POST["name"]) == "") {
	goprev();
}

if (! $_POST["no"] or trim($_POST["no"]) == "") {
	goprev();
}

// trim value
while (list($i, $j) = each($_POST)) {
	if ($i == "comment") continue;
	$a[$i] = trim($j);
}

include_once $global["lang"] . "/" . $_SESSION["config_lang"] . ".php";

$a["comment"] = $_POST["comment"];

$Site->DB->transaction_start(true);

$SQL_UPDATE_CARD =
	"update card_%s set
		name = '%s', email = '%s', work_phone = '%s', home_phone = '%s',
		fax = '%s', mobile = '%s', zip_work = '%s', country_work = '%s',
		city_work = '%s', add_work = '%s', title_work = '%s',
		department_work = '%s', organization_work = '%s', zip_home = '%s',
		country_home = '%s', city_home = '%s', add_home = '%s',
		homepage = '%s', comment = '%s' where no = '%s'";

$Site->DB->query(sprintf($SQL_UPDATE_CARD,
	$_SESSION["config_id"],
	addslashes($a["name"]), addslashes($a["email"]),
	addslashes($a["work_phone"]), addslashes($a["home_phone"]),
	addslashes($a["fax"]), addslashes($a["mobile"]),
	addslashes($a["zip_work"]), addslashes($a["country_work"]),
	addslashes($a["city_work"]), addslashes($a["add_work"]),
	addslashes($a["title_work"]), addslashes($a["department_work"]),
	addslashes($a["organization_work"]), addslashes($a["zip_home"]),
	addslashes($a["country_home"]), addslashes($a["city_home"]),
	addslashes($a["add_home"]), addslashes($a["homepage"]),
	addslashes($a["comment"]), $a["no"]));

$retval = $Site->DB->retval;
$Site->DB->close();

if ($retval) {
	$url = sprintf("Location: %s/mail?no=%s&pg=%s",
		$_SESSION["user_www_url"], $_SESSION["user_directory"],
		$_SESSION["user_page_number"]);

	$Site->end1();

	Header($url);
	exit;
} else {
	$Site->end1();

	goprev();
}

/*
Description
-----------

Author
------
 Spike^ekipS <spike@spikeekips.net>

Changelog
---------

Usage
-----

*/

?>
