I'm currently working on an assignment for my web development course. The premise is to create a simple "concert ordering site". Everything is well, but I keep running into this error message:
Notice: Undefined index: chooseTheAmountOfTickets in C:\xampp\htdocs\webtech\coursework\chapter05\event.php on line 22
Here's my PHP (Note: I do have the <?php
at the beginning):
$firstName = $_POST['firstName'];
$phoneNumber = $_POST['phoneNumber'];
$chooseTheAmountOfTickets = $_POST['chooseTheAmountOfTickets'];
$costOfTickets = 35;
$total = $chooseTheAmountOfTickets * $costOfTickets;
print("<p><b>Your total estimated cost is $$total. </b></p>");
?>]
Here's my HTML:
<form action = "event.php" method = "post">
<p>First Name
<input type = "text" size = "10" name = "firstName">
</p>
<form action = "event.php" method = "post">
<p>Phone Number
<input type = "text" size = "10" name = "phoneNumber">
<form action = "event.php" method = "post" >
<p>Choose the amount of tickets
<input type= "number" method = "post">
</p>
<p><i>Tickets will be $35 each not including tax and fees.</i></p>
<p>
<input type = "submit" value = "Calculate Tickets">
</p>
</form>
</p></td>
<td><b>$35 PER TICKET</b></td>
Your total estimated cost is $$total.
"); ```, you don't need $$total, just make it $total. $$total turns it into a variable variable which you can read about here: https://www.php.net/manual/en/language.variables.variable.php – Fly_Moe Oct 21 '20 at 20:26