Hi.
I am just in the very early stages of learning Php and just need a
little help.
I have a form which includes values. However when I test it, the
values are not added up and carried to the results page. I just
wondered if you can spot whats wrong with it?
This is the form on the page tourprice.php:
<form name="frm_tourp rice" id="frm_tourpri ce" method="post"
action="tourpri ce_processor.ph p">
<table width="60%" border="0" cellspacing="0" cellpadding="3" >
<tr>
<td>Number of Adults </td>
<td><input name="numAdults " type="text" id="numAdults"
/></td>
</tr>
<tr>
<td>Number of Children </td>
<td><input name="numChildr en" type="text" id="numChildren "
/></td>
</tr>
<tr>
<td>Tour Name </td>
<td><select name="tourName" id="tourName">
<option value="500">Hig hlights of Argentina</option>
<option value="700">Hig hlights of Western Canada</option>
<option value="900">Egy ptian Pyramids and More</option>
</select></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"
/></td>
</tr>
</table>
</form>
On the tourprice_calcu lator.php page it is supposed to add everything
up depending on what you select and give you the correct cost. I keep
getting a zero returned though.
This is at the top of tourprice_calcu lator.php
<?php
$numAdult = $_POST['numAdults'];
$numChild = $_POST['numChildren'];
$basePrice = $_POST['tourName'];
$tourPrice = (numAdult * basePrice) + (numChild * basePrice)
?>
Further down on the page I have the following:
Tour Price Calculator </h1>
<p>The estimated cost of your tour is <strong><?php echo
$tourPrice; ?></strong>.</p>
<p>Price includes hotel, accommodation, and travel expenses during
the tour. They do not include airfare to the starting destination.</p>
<p><a href="tourprice .php">Calculate </a> another tour.</p>
<p><a href="contact.p hp">Contact</a> one of our qualified
agents.</p>
Thanks very much for any help. Im a little confused with this one. I
thought it might be some of the strings like $Adult $Adults $Children
$Child etc that were wrong, but when I tried changing those it still
comes up as zero.
John
I am just in the very early stages of learning Php and just need a
little help.
I have a form which includes values. However when I test it, the
values are not added up and carried to the results page. I just
wondered if you can spot whats wrong with it?
This is the form on the page tourprice.php:
<form name="frm_tourp rice" id="frm_tourpri ce" method="post"
action="tourpri ce_processor.ph p">
<table width="60%" border="0" cellspacing="0" cellpadding="3" >
<tr>
<td>Number of Adults </td>
<td><input name="numAdults " type="text" id="numAdults"
/></td>
</tr>
<tr>
<td>Number of Children </td>
<td><input name="numChildr en" type="text" id="numChildren "
/></td>
</tr>
<tr>
<td>Tour Name </td>
<td><select name="tourName" id="tourName">
<option value="500">Hig hlights of Argentina</option>
<option value="700">Hig hlights of Western Canada</option>
<option value="900">Egy ptian Pyramids and More</option>
</select></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"
/></td>
</tr>
</table>
</form>
On the tourprice_calcu lator.php page it is supposed to add everything
up depending on what you select and give you the correct cost. I keep
getting a zero returned though.
This is at the top of tourprice_calcu lator.php
<?php
$numAdult = $_POST['numAdults'];
$numChild = $_POST['numChildren'];
$basePrice = $_POST['tourName'];
$tourPrice = (numAdult * basePrice) + (numChild * basePrice)
?>
Further down on the page I have the following:
Tour Price Calculator </h1>
<p>The estimated cost of your tour is <strong><?php echo
$tourPrice; ?></strong>.</p>
<p>Price includes hotel, accommodation, and travel expenses during
the tour. They do not include airfare to the starting destination.</p>
<p><a href="tourprice .php">Calculate </a> another tour.</p>
<p><a href="contact.p hp">Contact</a> one of our qualified
agents.</p>
Thanks very much for any help. Im a little confused with this one. I
thought it might be some of the strings like $Adult $Adults $Children
$Child etc that were wrong, but when I tried changing those it still
comes up as zero.
John
Comment