examle-program-1
example-program-1

Main File

<!DOCTYPE html>
<html>
<head>
<!--
Write an HTML document that contains an input 1ext box of collect a student name and have a checkbox to select the sport he likes watching form baseball, basketball,  football and vollyball form will be submited to file sport.php. write a php script that displays the name of student and the sport he likes.
-->
<title>Q3</title>
</head>
<body>
<br><br><br>
<center>
<form method="post" action="sport.php">
Name: <input type="text" name="student"><br><br>
Sport: <select multiple name="sports[]">
<option value="baseball">baseball</option>
<option value="basketball">basketball</option>
<option value="football">footballl</option>
<option value="vollyball">vollyball</option>
</select><br><br>
<input type="submit" name="submit" value="submit">
</form>
</center>
</body>
</html>

Sport.php File 

<?php
if(isset($_POST['submit']))
{
$student=$_POST['student'];
$sports=$_POST['sports'];
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Sports</title>
</head>
<body>
<h1><?php echo $student; ?></h1>

<?php foreach ($sports as $value) {
echo "<p>". $value ."</p><br>" ;
} ?>
</body>
</html>
<a href="q3.php">Go Back</a>