Location: PHPKode > projects > Kwalbum > kwalbum/ajax/delFavorite.php
<?php
/**
 * Remove an item from the user's favorites.
 *
 * @version 2.1.1
 * @package kwalbum
 * @since 2.1.1 Oct 23, 2008
 */

$dir = pathinfo(__FILE__, PATHINFO_DIRNAME).'/../include/';
require_once $dir.'DBConnection.php';
$DB = new DBConnection();
require_once $dir.'verifyLogin.php';
$errorMsg = '<p class="error">Favorite Not Removed!</p>';

if (!$id = (int)$P['id'])
{
	if (TEST_MODE)
		echo '<p class="error">Invalid ID</p>';
	else
		echo $errorMsg;
	exit;
}

if (USER_ID)
{
	$userId = USER_ID;
	$DB->Delete(FAVORITE_TABLE, "FavoriteUserIdFk=$userId AND FavoriteItemIdFk=$id");
	echo 'Favorite Removed';
}
else
	if (TEST_MODE)
		echo '<p class="error">Not Logged In</p>';
	else
		echo $errorMsg;

Return current item: Kwalbum