<?php require_once('Connections/conn_newland.php'); ?><?php 
// A small script generated by Dreamweaver to help with the dynamic query
require_once('Connections/conn_newland.php'); 
?>
<?php
// Queries the database for the tour name, adult price, and child price; data is filtered so that the only record retrieved corresponds to what the user entered in the form.
$colname_rs_tourprices_filtered = "-1";
if (isset($_POST['tourName'])) {
  $colname_rs_tourprices_filtered = (get_magic_quotes_gpc()) ? $_POST['tourName'] : addslashes($_POST['tourName']);
}
mysql_select_db($database_conn_newland, $conn_newland);
$query_rs_tourprices_filtered = sprintf("SELECT tourID, tourName, basePriceAdult, basePriceChild FROM tbl_tours WHERE tourID = %s", $colname_rs_tourprices_filtered);
$rs_tourprices_filtered = mysql_query($query_rs_tourprices_filtered, $conn_newland) or die(mysql_error());
$row_rs_tourprices_filtered = mysql_fetch_assoc($rs_tourprices_filtered);
$totalRows_rs_tourprices_filtered = mysql_num_rows($rs_tourprices_filtered);

// Form validation script; redirects user back to tourprice.asp if form fields do not have numeric values.
if (is_numeric($_POST['numAdults']) == false or is_numeric($_POST['numChildren']) == false)
{
	header("Location: tourprice.php?error=notnumeric&tourID=".$_POST['tourName']);
	exit;
}

// Collects data for number of adults and children, and the prices for both adults and children; multiplies data to calculate total.
$numAdult = $_POST['numAdults'];
$numChild = $_POST['numChildren'];
$basePriceAdult = $row_rs_tourprices_filtered['basePriceAdult'];
$basePriceChild = $row_rs_tourprices_filtered['basePriceChild'];
$tourPrice = ($numAdult * $basePriceAdult) + ($numChild * $basePriceChild)
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Newland Tours: Tour Price Calculator</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<link href="css/newland.css" rel="stylesheet" type="text/css" />
</head>

<body>
<a href="#top"><img src="images/spacer.gif" alt="Skip to main page content" width="1" height="1" border="0" align="left" /></a>
<table width="750" border="0" cellpadding="3" cellspacing="0">
 <tr>
  <td><img src="images/banner_left.gif" width="451" height="68" alt="Newland Tours Banner, Left." /></td>
  <td width="280"><img src="images/banner_right.jpg" width="276" height="68" alt="Newland Tour Banner, Right." /></td>
 </tr>
 <tr>
  <td><img src="images/navbar.gif" name="navbar" width="450" height="20" border="0" usemap="#navbarMap" alt="Navigation Bar." /></td>
  <td><img name="copyright_bar" src="images/copyright_bar.gif" width="272" height="20" border="0" alt="Copyright 2006 Newland Tours." /></td>
 </tr>
 <tr>
  <td colspan="2">	
	<h1><br />
	  <a name="top" id="top"></a>Kalkulator ceny wyjazdu </h1>
    <p>Przybli&#380;ony koszt wybranego przez Ciebie wyjazdu, <strong><?php echo $row_rs_tourprices_filtered['tourName']; ?></strong>, wynosi <strong><?php echo number_format($tourPrice, 0,"."," "); ?> zł</strong>.</p>
    <p>Podana cena obejmuje nocleg, hotel i inne wydatki zwi&#261;zane z podr&oacute;&#380;ami podczas wyjazdu. Nie zawiera natomiast op&#322;at lotniskowych.</p>
    <p><a href="tourprice.php">Oblicz cen&#281;</a> innego wyjazdu.</p>
    <p><a href="contact.php">Skontaktuj si&#281;</a> z jednym z naszych wykwalifikowanych agent&oacute;w. </p></td>
 </tr>
</table>

<br />


<map name="navbarMap" id="navbarMap">
 <area shape="rect" coords="1,0,62,20" href="index.php" alt="Home" />
 <area shape="rect" coords="71,0,117,20" href="about.php" alt="About" />
 <area shape="rect" coords="129,0,196,20" href="tours.php" alt="Find Tours" />
 <area shape="rect" coords="209,0,311,20" href="profiles.php" alt="Country Profiles" />
 <area shape="rect" coords="327,0,434,20" href="contact.php" alt="Contact An Agent" />
</map>
</body>
</html>
<?php
mysql_free_result($rs_tourprices_filtered);
?>