I have a problem to do price data and i don’t know to insert it into the coding
this is question
this is the coding that i have made
<?php
$page_title = 'Yoho Express!';
include ('includes/header.html');
?>
<form action="q2.php" method="post">
<p><h1><fieldset><legend>Enter your information in the form below:</legend></p></h1>
<p><b>Departure day:</b>
<?php
//This programme is display in an array.
$day = array (1 =>'Select',
'Saturday',
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday');
//the programme is display using the pull-down menu.
echo '<select name="day">';
foreach ($day as $key => $value) {
echo "<option value=\"$value\">$value</option>\n";
}
echo '</select>';
?></p>
<p><b>Departure time:</b>
<?php
//This programme is display in an array.
$time = array (1=>'Select',
'7:00',
'10:00',
'13:00',
'16:00',
'21:00');
//the programme is display using the pull-down menu.
echo '<select name="time">';
foreach ($time as $key => $value) {
echo "<option value=\"$value\">$value</option>\n";
}
echo '</select>';
?>
</fieldset>
<b><p><div align="left"><input type="submit" name="submit" value="Book" /></div></b></p>
</form>
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
//handler
// Validate day
if (!empty($_POST['day'])) {
$day = $_POST['day'];
} else {
$day = NULL;
echo '<p><b><font color="purple">You forgot to enter your departure day!</b></p>';
}
// Validate time
if (!empty($_POST['time'])) {
$time = $_POST['time'];
} else {
$time = NULL;
echo'<p><b><font color="purple">You forgot to enter your departure time!</b></p>';
}
// Validate price
if (!empty($_POST['price'])) {
$price = $_POST['price'];
} else {
price= NULL;
}
// If everything is okay, print the message.
if ($day && $time && $price) {
// Print the submitted information.
echo "<b><font color='purple'>Below are your bus ticket details </font></b></p>
<br /><b>Day:</b>$day
<br /><b>Time:</b>$time
<br /><b>Price No:</b>$price";
} else {
// One form element was not filled out properly.
echo '<p><font color="red">Please go back and fill out the form again.</font></p>';
}
}
include('includes/footer.html');
?>