<?php
require_once('./admin.php');
$Action = $_GET['action'];
//if any new element is defined, extratct it away
$NewElement['name'] = trim($_POST['new']);
$NewElement['value'] = trim($_POST['newv']);
unset($_POST['new']);
unset($_POST['newv']);
//extracting the information as an array
foreach($_POST as $Key => $KeyValue)
{
$MainID = intval($Key);
if(substr($Key, -1, 1) === 'v')
{
$InterestElement[$MainID]['value'] = $KeyValue;
}
else
{
$InterestElement[$MainID]['name'] = $KeyValue;
}
}
//update in database
if(!empty($InterestElement))
{
foreach($InterestElement as $Key => $KeyValue)
{
$DC->Result('UPDATE '.PR_DATABASE_PREFIX."profile SET profile_name = '{$KeyValue['name']}', profile_value = '{$KeyValue['value']}', profile_category = 'Interest' WHERE profile_id = {$Key}");
}
}
//insert new element
if(!empty($NewElement['name']))
{
if(empty($NewElement['value']))
{
die('Text field for the new element is empty');
}
else
{
$DC->Result('INSERT INTO '.PR_DATABASE_PREFIX."profile SET profile_name = '{$NewElement['name']}', profile_value = '{$NewElement['value']}', profile_category = 'Interest'");
}
}
header("Location: profile-interest.php?highlight=Updated_the_\"Interest\"_category");
?>