Location: PHPKode > projects > Prsaar Social Networking Platform > PrsaarColour-0.7.alpha.6.3/pr-admin/option-link-update.php
<?php
	require_once('admin.php');
	
	//Add new link----------------------------------
	if($Action == 'link_new')
	{
		if(empty($_POST['link_name']))
			$Error['link_name'] = 'Please provide a name ';
		if(empty($_POST['link_url']))
			$Error['link_url'] = 'Please provide the URL for the link';
		if(empty($_POST['link_category']))
			$Error['link_category'] = 'Please provide a category for your link';
		if(isset($Error))
		{
			$Action = 'newlink';
			require('option-link-edit.php');
			exit();
		}
		else
		{
			$LinkName = str_replace("'", "&#39;", $_POST['link_name']);
			$LinkURL = str_replace("'", "&#39;", $_POST['link_url']);
			$LinkCategory = str_replace("'", "&#39;", $_POST['link_category']);
			$DC->Result("INSERT INTO ".PR_DATABASE_PREFIX."link SET link_name = '{$LinkName}', link_url = '{$LinkURL}', link_category = '{$LinkCategory}'");
			header("Location: option-link.php?highlight=new_link_added");
			exit();
		}
	}
	//----------------------------------------------
	if($Action === 'link_delete')
	{
		$ID = $_GET['id'];
		die("Are you sure you want to delete this link, this is irreversible. <a href='option-link-update.php?action=link_deletenow&id=$ID'>Delete Now</a> <a href='option-link.php'>Cancel</a>");
	}
	
	//---------------------------------------------------- Link Delete now
	if($Action === 'link_deletenow')
	{
		$ID = $_GET['id'];
		$DC->Result("DELETE FROM ".PR_DATABASE_PREFIX."link WHERE link_id = $ID");
		header("Location: option-link.php?highlight=Link deleted");
		exit();
	}
	
	//Update Edited Link------------------------------------------
	if($Action === 'link_edit')
	{
		{
			if(empty($_POST['link_name']))
				$Error['link_name'] = 'Please provide a name ';
			if(empty($_POST['link_url']))
				$Error['link_url'] = 'Please provide the URL for the link';
			if(empty($_POST['link_category']))
				$Error['link_category'] = 'Please provide a category for your link';
			if(isset($Error))
			{
				$Action = 'edit';
				require('option-link-edit.php');
				exit();
			}
			else
			{
				$ID = $_GET['id'];
				$LinkName = str_replace("'", "&#39;", $_POST['link_name']);
				$LinkURL = str_replace("'", "&#39;", $_POST['link_url']);
				$LinkCategory = str_replace("'", "&#39;", $_POST['link_category']);
				$DC->Result("UPDATE ".PR_DATABASE_PREFIX."link SET link_name = '{$LinkName}', link_url = '{$LinkURL}', link_category = '{$LinkCategory}' WHERE link_id = $ID");
				header("Location: option-link.php?highlight=link_edited");
				exit();
			}
		}
	}
?>
Return current item: Prsaar Social Networking Platform