Order Form will not display any dollar amounts after Submitting

I am working on a school assignment and whenever I hit Submit in my HTML page to continue onto my PHP page, it won’t show the correct dollar amounts. It will only show $0 and I have no idea where I am going wrong. I’m quite new to this and the class is a college course that is online so I cannot easily/directly ask the professor. Help!

HTML code:

Book Sale

 

Samantha's Textbooks

		<tr>
		<td width='42%' align='center'><img src='images/WinterLodge.jpg' width='300' height='300' alt='book2' /></td>
		<td width='30%' align='center'>Title
		<input type='text' name='title2' disabled='disabled' value='The Winter Lodge' /></td>
		<td width='12%' align='center'>Price
		<input type='text' name='price2' disabled='disabled' value='$14.00' size='7' /></td>
		<td width='16%' align='center'>Quantity
			<select name='qty2'>
				<option value='0'>0</option>
				<option value='1'>1</option>
				<option value='2'>2</option>
				<option value='3'>3</option>
				<option value='4'>4</option>
			</select></td>
		</tr>
		
		<tr>
		<td width='42%' align='center'><img src='images/Driftwood.jpg' width='300' height='300' alt='book3' /></td>
		<td width='30%' align='center'>Title
		<input type='text' name='title3'  disabled='disabled' value='Driftwood Cottage' /></td>
		<td width='12%' align='center'>Price
		<input type='text' name='price3' disabled='disabled' value='$8.00' size='7' /></td>
		<td width='16%' align='center'>Quantity
			<select name='qty3'>
				<option value='0'>0</option>
				<option value='1'>1</option>
				<option value='2'>2</option>
				<option value='3'>3</option>
				<option value='4'>4</option>
			</select></td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td align='center'><input type='submit' value='Submit' /></td>
		<td align='center'><input type='reset' value='Reset' /></td>
		</tr>
		</table>
		<p>&nbsp;</p>
		<p>&nbsp;</p>
		<p>&nbsp;</p>
		<p>&nbsp;</p>
	</form>
	</body>
	</html>

PHP code:

Order Information

Textbook Order Information

<?php
		$customer = $_POST['customer'];
		
		$qty1 = $_POST['qty1'];
		$price1 = $_POST['price1'];
		$itemTotal1 = $_POST['qty1'] * $_POST['price1'];
		
		$qty2 = $_POST['qty2'];
		$price2 = $_POST['price2'];
		$itemTotal2 = $_POST['qty2'] * $_POST['price2'];
		
		$qty3 = $_POST['qty3'];
		$price3 = $_POST['price3'];
		$itemTotal3 = $_POST['qty3'] * $_POST['price3'];
		
		$subTotal = $itemTotal1 + $itemTotal2 + $itemTotal3;
		
		$salesTax = $subTotal * .06;
		
		$finalOrder = $subTotal + $salesTax; 

print ("<p>Your subtotal is $$subTotal.</p>"); 

print ("<p>Your sales tax is $$salesTax.</p>");

print ("<p>Your final order amount is $$finalOrder.</p>");

?>
Customer Name
book1 Title Price Quantity 0 1 2 3 4

Hi,

You can use builtin number_format() function of PHP. So to display your $subTotal:

echo "Your sub total is: ". number_format( $subTotal, 2, ‘.’, ‘,’);

It should display something like $1,234.56

Sponsor our Newsletter | Privacy Policy | Terms of Service