Location: PHPKode > projects > Kwalbum > kwalbum/ajax/editPeopleValue.php
<?php
/* 2.0.3: 2008-10-03
 * 2.0 created: 2008-09-04
 */
require_once pathinfo(__FILE__, PATHINFO_DIRNAME).'/../include/verifyLogin.php';
require_once pathinfo(__FILE__, PATHINFO_DIRNAME).'/../include/DBConnection.php';
$DB = new DBConnection();
$errorMsg = '<span class="error">Change Not Saved!</span>';

$id = (int)$P['id'];
if (empty($P['name']))
	$name = '';
else
	$name = trim($DB->FilterString($P['name']));

if (USER_IS_ADMIN and 0 < $id)
{
	if (!empty($name))
	{
		if ('-----' != $name)
			$DB->UpdateSingle(PEOPLE_TABLE, 'PeopleName',
				"'$name'", "PeopleId='$id'");
		else
		{
			$DB->Delete(PEOPLE_TABLE, "PeopleId='$id'");
			$DB->Delete(PEOPLE_MAP_TABLE, "PeopleIdFk='$id'");
			echo '';
			exit();
		}
	}
	else
	{
		$row = $DB->Query('SELECT PeopleName FROM '.PEOPLE_TABLE.' WHERE PeopleId='.$id)->fetch_array();
		$name = $row[0];
	}
	echo $name;
}
else
	if (TEST_MODE)
		echo '<span class="error">Invalid Permissions.</span>';
	else
		echo $errorMsg;

Return current item: Kwalbum