Location: PHPKode > projects > Coxiar Media Platform > coxiar_productions/cpanel/add_categories.php
<?php
set_time_limit(0);
session_start();
include("../db.php");
require_once '../widget/widget_categories.php';
$Categories = new Widget_Categories();
if(isset($_SESSION['logged_in']) != true) 	exit; 
$Msg = '';
$emode = (isset($_GET['emode'])) ? $_GET['emode'] : 'V';

if(isset($_POST['TheFunction'])){
	$emode = $_POST['emode'];
	$uploaddir = '../category_images/';
	$uploadfile_temp = date('HiSu').rand(1, 10).basename($_FILES['timage']['name']);
	$uploadfile_date = date('Y-m-d');
	$uploadfile = $uploaddir.$uploadfile_date.'/'.$uploadfile_temp;
	if(file_exists($uploaddir.$uploadfile_date.'/') != true){
		mkdir($uploaddir.$uploadfile_date.'/');
	}

	$tid = (isset($_POST['ttid'])) ? $_POST['ttid'] : '';
	$sqlx = '';
	if (move_uploaded_file($_FILES['timage']['tmp_name'], $uploadfile)) {
		exec($config['mogrify'].' -format gif -thumbnail 125x100 "'.realpath($uploadfile).'"');
		if($_POST['Mode'] == "1"){
			if($tid == ''){
				$sql1 = "INSERT INTO ";
			}
			else{
				$sql1 = "UPDATE ";
				$sqlx = " Where `category_id` = '".$tid."'";
			}
		$sql = $sql1."`categories` Set `category_name` = '".$_POST['tcategory_name'.$tid]."' ".
							", `category_image` = '".str_replace('../category_images/','',$uploadfile)."' ".
							", `category_sub` = '".$_POST['tcategory_sub'.$tid]."' ".
							", `category_type` = '".$emode."'".$sqlx;
		}
		else{

				$sql3 = "Delete from `login` Where `user_id` = '".$tid."'";
				$sql = "Delete from `login_details` Where `user_id` = '".$tid."'";

				mysql_query($sql3);

		}
		//echo $sql;
		//exit;
		mysql_query($sql);
		$Msg = 'Category Added';
	}
	else{
		
		$Msg = 'Error adding category. Please make sure the picture is less than 100Mb';
	}

}

?>
<html>
<head>
<title>Edit Categories</title>
<style type="text/css">
<!--
body {
	background-color: black;
}
h1{
font-size:20px;
font-family:Arial, Helvetica, sans-serif;
}
div, td, tr, table, p{
font-size:10px;
font-family:Arial, Helvetica, sans-serif;
color:white;
}
a:link {
	color:white;
	text-decoration: underline;
}
a:visited {
	color:white;
	text-decoration: underline;
}
a:hover {
	text-decoration: underline;
	color:white;
}
a:active {
	text-decoration: underline;
	color:white;
}
input{

font-size:10px;
font-family:Tahoma;

-->
</style>
<script language="Javascript">
function selectedItem(tid, mode){
	if(mode == 3){
	alert('Feature not available yet =X');
	return false;
	}

	document.DataEntry.ttid.value = tid;
	document.DataEntry.Mode.value = mode;
	document.DataEntry.submit();
	return true;
}
</script>
</head>
<body>
<br>
<div align="center">
<img src="../images/easy_tms.php?text=<?=urlencode('Add Category - '.(($emode == 'V') ? 'Videos' : 'Stills'))?>&font_size=13"><br>
<br><br>
<?=$Msg?>
<br><br>
<form action="<?=$_SERVER['PHP_SELF']?>" onsubmit="return false;" name="DataEntry" method="POST"  enctype="multipart/form-data">
<input type="hidden" name="Mode">
<input type="hidden" name="ttid" value=" ">
<input type="hidden" name="TheFunction" value="1">
<input type="hidden" name="emode" value="<?=$emode?>">

	<div style="border: 1px white solid; height:125px; width:400px;">
	<div style="position:relative; left:75px; top:25px; bottom:25px;">
	<table width="400" border="0" cellspacing="0" cellpadding="0" >
	<tr>
	<td rowspan="4" border="0">
	

	</td>
	</tr>

	<tr>
	<td>
	Name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<input type="text" name="tcategory_name" value="">
	</td>
	</tr>

	<tr>
	<td>
	Image &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="file" name="timage" size="35"/>
	</td>
	</tr>

	<tr>
	<td>
	Category of &nbsp; 
	<?
	if($emode == 'V'){
		echo $Categories->Videos_Combobox('tcategory_sub', '');
	}
	else{
		echo $Categories->Stills_Combobox('tcategory_sub', '');
	}
	?>
	</td>
	</tr>

	<tr>
	<td>
		&nbsp;
	</td>
	<td>
	<img src="../images/easy_tms.php?text=Save&font_size=13" onclick="selectedItem('', 1);">

	</td>
	</tr>
	</table>
	</div>
	</div>
	<br><br>


</form>

</div>
</body>
</html>
Return current item: Coxiar Media Platform