<!doctype html> <META HTTP-EQUIV=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\"> <html l
ID: 3706936 • Letter: #
Question
<!doctype html>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<html lang="en">
<head>
<title> Lecture 19 - Today In History</title>
<link rel="stylesheet" href=“hw10.css">
</head>
<body>
<form action=“hw10.php” method=“post”>
<input type=“radio” name=“site” value=“Roatan”> Roatan </input> <br/>
<input type=“radio” name=“site” value=“Bonaire”> Bonaire </input> <br/>
<input type=“radio” name=“site” value=“Grand Cayman”>Grand Cayman </input> <br/>
<input type=“radio” name=“site” value=“Key Largo”> Key Largo</input> <br/>
<input type=“radio” name=“site” value=“Key west”>Key west </input> <br/>
<input type=“radio” name=“site” value=“Aruba”> Aruba </input> <br/>
<input type=“radio” name=“site” value=“Queensland”>Queensland </input> <br/>
<input type=“radio” name=“site” value=“Kailua Kona”>Kailua Kona </input> <br/>
<input type=“radio” name=“site” value=“Belize”> Belize </input> <br/>
<input type=“radio” name=“site” value=“Bali”> Bali </input> <br/>
<input type=“radio” name=“site” value=“Cozumel”> Cozumel </input> <br/>
<input type=“submit” name=“submit” value=“Submit”/> <br/>
<?
$site = _POST['site'];
$event = file('dives.txt');
print ‘<table>
<tr>
<th> Dive Type </th>
<th>Duration </th>
<th> Depth </th>
</tr>’;
foreach ($event as $thing){
$fields = explode (",",$thing);
if($site == $filed[0]) {
print “<tr>
<td>$fields[2] </td>
<td> $fields[3] </td>
<td> $field[0] </td>
</tr>“;
$number++;
}}
print "$number eventes happend in this day";
?>
</form>
</body>
</html>
Explanation / Answer
The $site variable in your hw10.php file is erroneous because when a form is submitted the values of various elements in the form in your case radio buttons are submitted with the corresponding name attribute's value as an identifier.
So if in the form you changed the attribute values of name attributes of the radio buttons from simply name to name1, name2, name3 and so on. These values will be available in the variable $site upon submission.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.