php/html if else statement help

i am trying to make my code display txt saying that they need to enter information if the txtname,cboBase,radSize and chk options arent selected. if they are then total up the options but i receive an error : Parse error: syntax error, unexpected ‘else’ (T_ELSE) in C:\xampp\htdocs\serverCode\pizza.php on line 20

<?php $name = $_POST["txtName"]; $base = $_POST["cboBase"]; $size = $_POST["radSize"]; $opt = $_POST["chkOptions"]; $num = count($opt); $cost = array_sum($opt); if(!empty($_POST["cboBase"]) && ($_POST["radSize"]) && ($_POST["chkOptions"]) && ($_POST["txtName"])); $subtotal = $cost + $base; $total = $subtotal + $cost; { echo "Thank you for your order, $name. Here are your order details:
Subtotal: $subtotal
Number of Options: $num
Options Total: $cost
Total: $total"; } else { echo"please enter information"; } ?> Pizza Order Form
Name:
Phone:
	<div class="row">
		<div class="cell">Base Pizza:</div>
		<div class="cell">
			<select id="cboBase" name="cboBase">
				<option value="0">Select a starter pizza ...</option>
				<option value="10.25">Canadian Eh! -- $10.25</option>
				<option value="12.00">Hawaiian -- $12.00</option>
				<option value="12.50">Chili Dawg -- $12.50</option>
				<option value="15.00">Meat Lover's Deluxe -- $15.00</option>		   
			</select>
		</div>
	</div>
	<div class="row">
		<div class="cell">Pizza Size:</div>
		<div class="cell">
			<input type="radio" name="radSize" id="radSmall" value="0">Small
			<input type="radio" name="radSize" id="radMedium" value="5">Medium
			<input type="radio" name="radSize" id="radLarge" value="7">Large
		</div>

	</div>
	<div class="row">
		<div class="cell">Options:</div>
		<div class="cell">
			<input type="checkbox" name="chkOptions[]" id="chkExtraCheese" value=".5">Extra Cheese
			<input type="checkbox" name="chkOptions[]" id="chkExtraSauce" value=".25">Extra Sauce
			<input type="checkbox" name="chkOptions[]" id="chkOlives" value=".75">Olives
			<input type="checkbox" name="chkOptions[]" id="chkAnchovies" value=".75">Anchovies
		</div>
	</div>
</div>

[php]<?php

$name = $_POST[“txtName”];
$base = $_POST[“cboBase”];
$size = $_POST[“radSize”];
$opt = $_POST[“chkOptions”];
$num = count($opt);
$cost = array_sum($opt);

if(!empty($_POST[“cboBase”]) && ($_POST[“radSize”]) && ($_POST[“chkOptions”]) && ($_POST[“txtName”])){
$subtotal = $cost + $base;
$total = $subtotal + $cost;
echo “Thank you for your order, $name. Here are your order details:

Subtotal: $subtotal

Number of Options: $num

Options Total: $cost

Total: $total”;
}
else
{
echo"please enter information";
}
?>[/php]

Ensure your if statements are syntaxed correctly with { }

thanks for the help. i didnt see that i missed the brackets. i put them in and im still having the same issue.
Parse error: syntax error, unexpected ‘{’, expecting ‘(’ in C:\xampp\htdocs\serverCode\pizza.php on line 11

dont get any syntax issues on my end. you have issues though.

what happens if people dont select extras?
$_POST[“chkOptions”] will be empty and it will output need more info.

$opt = $_POST[“chkOptions”]; will also output an error.
check post data before you assign to a variable and output error there.

Sponsor our Newsletter | Privacy Policy | Terms of Service