session_start(); // Start the session
header("Cache-control: private");
//Get Username from Session
$username_sess = $_SESSION['id'];
if($username_sess == ""){ //Session user id has been destroyed or not set - show re-login page
echo "";
}
//Open a connection to the database server
$connection = pg_connect ("dbname=greenasap host=pwarisk.homeip.net user=gisadmin password=spatial");
if (!$connection){
die("Could not open connection to database server");
}
//Get the variables to enable the site coordiates to be written to the orders database
$orderNo = $_POST["storedorderno"];
$theaddress = $_POST["storedaddress"];
$theReportType = $_POST["storedreporttype"];
// puting variables in to session
$_SESSION['theaddress'] = $theaddress;
$theaddress_ses= $_SESSION['theaddress'];
$_SESSION['orderNo'] = $orderNo;
$theOrderNo= $_SESSION['orderNo'];
$theprice = 0;
//Retrieve price from the database
$qstring = "select price from reportprice where report_type = '$theReportType'";
$result = pg_query($connection, $qstring);
if($result){
while ($row = pg_fetch_array($result)){
$currentOrderPrice = $row[0];
}
if($currentOrderPrice > 0){
//Add coordinates and price to the orders table
$qstring = "update cust_order set price=$currentOrderPrice where orderno='$theOrderNo'";
$result = pg_query($connection, $qstring);
if($result){
$theprice = $currentOrderPrice;
}
}
}
//putting price in to session variable
$_SESSION['theprice'] = $theprice;
$price_ses= $_SESSION['theprice'];
?>


