<?php

session_start();
if($HTTP_SESSION_VARS['dbName']==""){
header("location:../index.php");
}

include("config.inc.php");

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($HTTP_SESSION_VARS['dbName'],$connection) or die("Could not find DB");

if($mode=='insert'){


$query ="insert into warehouse(warehouse_code,warehouse_name)
values('$warehouse_code','$warehouse_name')";


$result=mysql_query($query,$connection);
	$message    = mysql_error();	
}

if($mode=='edit'){


$query="update warehouse
       set warehouse_code='$warehouse_code',
	   warehouse_name='$warehouse_name'
	   where warehouse_code='".$warehouse_code."'";
	   
	//   echo $query;exit;
	
	   $result=mysql_query($query,$connection);
	   
 }
	   
if($mode=='delete'){
	$query="delete from  warehouse where  warehouse_code='".$warehouse_code."'";
	$result=mysql_query($query,$connection);   
	 }

  
if($mode=='delete')
	header ("location: ./form_Warehousesearch1.php?mode=view&warehouse_code=$warehouse_code");

else	  
	header ("location: ./form_Warehouse1.php?mode=view&warehouse_code=$warehouse_code");

?>