<?php
require_once '../../library/config.php';
require_once '../library/functions.php';
require_once '../library/logged.php';
require_once '../../library/validation.php';


if (isset($_POST['field'])){
	$id = isNumber(trim($_POST['id']));
	$field = txt_only($_POST['field']);
	$val = htmlPurify($_POST['val']);
	
	mysql_query('UPDATE `product_list` SET `'.$field.'` = "'.$val.'" WHERE `p_id` = '.$id, $connePaper);
	
	mysql_close($connePaper);
}
if (isset($_POST['action'])){
	if ($_POST['action'] == 'add_value'){
		$m_p_id = isNumber($_POST['m_p_id']);
		$m_o_id = isNumber($_POST['m_o_id']);
		$val = htmlPurify($_POST['val']);
		$field = txt_only($_POST['lang']);
		
		mysql_query("INSERT INTO `options_value` ($field, match_p_id, match_option_id) VALUES ('$val', '$m_p_id', '$m_o_id')", $connePaper);
	}
	if ($_POST['action'] == 'update_value'){
		$val = htmlPurify($_POST['val']);
		$field = txt_only($_POST['lang']);
		$id = isNumber(trim($_POST['v_id']));
		
		mysql_query('UPDATE `options_value` SET `'.$field.'` = "'.$val.'"  WHERE `value_id` = '.$id, $connePaper);
	}
	mysql_close($connePaper);
}

?>
