<?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')
{
$AboutMeElement[$MainID]['value'] = $KeyValue;
}
else
{
$AboutMeElement[$MainID]['name'] = $KeyValue;
}
}
//update in database
if(!empty($AboutMeElement))
{
foreach($AboutMeElement as $Key => $KeyValue)
{
$DC->Result('UPDATE '.PR_DATABASE_PREFIX."profile SET profile_name = '{$KeyValue['name']}', profile_value = '{$KeyValue['value']}', profile_category = 'About me' 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 = 'About me'");
}
}
header("Location: profile-aboutme.php?highlight=Updated_the_\"About me\"_category");
?>