<?php

session_start();

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

include("config.inc.php");
if($config['log_file'] == 1){
$connection_history = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass'],true,65536) or die("Could not connect to DB");
mysql_select_db($config['dbName_history'],$connection_history) or die("Could not find DB");
}

$query_user_name = "select User_Name from ".$_SESSION['dbLabel'].".users where user_account='".$_SESSION['useraccount']."'";
$result_user_name = mysql_query($query_user_name, $connection);
$rows_user_name = mysql_fetch_array($result_user_name);
extract($rows_user_name);

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

$Sordervehicleweight     = $_POST["Sordervehicleweight"]; if ($Sordervehicleweight == ""){$Sordervehicleweight = $_GET["Sordervehicleweight"];}  
$SorderID     = $_POST["SorderID"]; if ($SorderID == ""){$SorderID = $_GET["SorderID"];}  
$startrange     = $_POST["startrange"]; if ($startrange == ""){$startrange = $_GET["startrange"];}  
$message     = $_POST["message"]; if ($message == ""){$message = $_GET["message"];}  

echo "if ($Sordervehicleweight!='' and $SorderID!='')";
if ($Sordervehicleweight!='' and $SorderID!='')
{ 
	$q = "update sorder set Sorder_vehicleweight = '".$Sordervehicleweight."' where  sorder_id = ".$SorderID ;
	$result = mysql_query($q,$connection) or die(mysql_error());
	$message  = mysql_error(); 
	
	if($config['log_file'] == 1){
		
		$q = "insert into sorder ( Sorder_vehicleweight , sorder_id,sorder_history_date,sorder_history_operator_id,sorder_history_schema,sorder_history_status) values('$Sordervehicleweight','$SorderID',now(), '".$User_Name."', '".$_SESSION['dbName']."', 'D')" ;
	$result = mysql_query($q,$connection_history) or die(mysql_error());
	$message  = mysql_error();  }
	
	header ("Location: ./Form_VehicleLoad.php?SorderID=".$SorderID."&message=".$message."&startrange=".$startrange."&perpage=".$perpage);
	
}


?>