<?php

session_start();


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

include("config.inc.php");
include("function.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");

//User Access
$querylog=" select ifNull(login_belongstogrp,0) As FI_BelongsToGrp from ".$HTTP_SESSION_VARS['dbLabel'].".login where user_account='".$HTTP_SESSION_VARS['useraccount']."' and Upper(Login_Schema) = Upper('".$HTTP_SESSION_VARS['dbName']."')  ";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}


$vehicletype_description = ereg_replace("'", "\'", $vehicletype_description);


if($actionmode=='insert'){
		
	$query="Insert into vehicletype (vehicletype_description)
			values ('".$vehicletype_description."')";


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

			   

}

if($actionmodedelete=='delete')
{	
	$query="delete from vehicletype where vehicletype_id='".$vehicletypeid."'";
	//echo$query;exit;
	$result  = mysql_query($query, $connection);
	$message = mysql_error();

	
}


if($actionmode=='editmode'){
	$query_update=" update vehicletype set	vehicletype_description='".$vehicletype_description."' ".		  
					  "	where vehicletype_id='".$vehicletype_id."'";
					  
					  
	$resultedit = mysql_query($query_update, $connection);
	$message    = mysql_error();


}

$message = ereg_replace(' ','%20',$message);

if($actionmode=='delete')			   
	header ("Location: ./Form_TrackingTypeSearch.php?vehicletype_Id=$vehicletype_Id&mode=view&message=".$message);
else
	header ("Location: ./Form_TrackingType.php?vehicletype_Id=$vehicletype_Id&mode=view&message=".$message);

mysql_close($connection);



?>