Location: PHPKode > projects > Simple PHP Shopping cart - asaancart > asaancart v-0.9/admin/edit_brand.php
<?php
session_start();
/*
asaancart - easy shopping cart solution
---------------------------------------

Copyright 2009 Nasir Ahmad Khan
Email: hide@address.com

This file is part of asaancart - open source easy shopping cart solution.

asaancart is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

asaancart is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with asaancart.  If not, see <http://www.gnu.org/licenses/>.

*/

include("../config/config.php");
include("includes/chk_login_status_inc.php");

$smarty->assign('title','Edit Brand');

$brand_id = $_POST['brand_id'];
if ($brand_id==""){
$brand_id = $_GET['brand_id'];
}
$brand_name = $_POST['brand_name'];
$brand_intro = $_POST['brand_intro'];
$brand_intro = str_replace("'","\'",$brand_intro);
$brand_logo = $_POST['brand_logo'];
$brand_logo_new = $_POST['brand_logo_new'];

$uploaddir = $_SERVER['DOCUMENT_ROOT'].'/'.APP_ROOT_DIR.'/brand_images/';
	//	echo $uploaddir;
if($_POST['btn_create']=="Save")
{	
			
			//upload logo
			
			if(basename($_FILES['brand_logo_new']['name'])!=''){
				$uploadfile = $uploaddir ."$brand_name"."_".basename($_FILES['brand_logo_new']['name']);
				$image_filename = "$brand_name"."_".basename($_FILES['brand_logo_new']['name']);
				//echo $image_filename;
				if (move_uploaded_file($_FILES['brand_logo_new']['tmp_name'], $uploadfile)) {
				//echo "File is valid, and was successfully uploaded.\n";
				} else {
					$smarty->assign('msg_brand','Possible file upload attack!');
				}
				$uploadfile = "";
			} //end if 
			
			
			
		//inser into product table 
		if (basename($_FILES['brand_logo_new']['name'])!=""){
		$sql = "UPDATE brands SET brand_name='".$brand_name."', brand_intro='".$brand_intro."', brand_logo='".$image_filename."' WHERE brand_id=$brand_id";
		}else{
		$sql = "UPDATE brands SET brand_name='".$brand_name."', brand_intro='".$brand_intro."' WHERE brand_id=$brand_id";
		}
		$results = mysql_query($sql);
		$smarty->assign('msg_brand','Done: Updated Successfully');
		

}

//show brand values
$sql = "SELECT * FROM brands WHERE brand_id=$brand_id";
$results = mysql_query($sql);
while($row = mysql_fetch_assoc($results) )
{
	$selected_brand[] = $row;
}
$smarty->assign('selected_brand', $selected_brand);

$smarty->display('edit_brand.tpl');
?>
Return current item: Simple PHP Shopping cart - asaancart