Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
20 views5 pages

Practical 11 (A)

The document provides PHP code examples for designing web forms using list boxes, combo boxes, and hidden fields. It includes two exercises: the first allows users to select a novel and a game, while the second focuses on selecting a favorite fruit and color. Each form processes input and displays the selected values upon submission.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views5 pages

Practical 11 (A)

The document provides PHP code examples for designing web forms using list boxes, combo boxes, and hidden fields. It includes two exercises: the first allows users to select a novel and a game, while the second focuses on selecting a favorite fruit and color. Each form processes input and displays the selected values upon submission.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Subject :- Web Based Application Development with PHP Subject Code :- 22619

Name :- Shivam Sainath Korpakwad Batch :- CO 6 IA Roll No. 24


Program Code :-
1) Write a program to design a form using list box, combo box and hidden field box.
CODE :-
<html>
<head>
<title>Form Design</title>
</head>
<body>
<h2>Form Design with PHP</h2>
<form method="post" action="index.php">
<label for="listBox">
Select a Novel from list box:
</label>
<br>
<select name="listBox" id="listBox" size=”4”>
<option value="swami">Swami</option>
<option value="yugandhar">Yugandhar</option>
<option value="yayati">Yayati</option>
<option value="chawa">Chawa</option>
</select>
<br><br>
<label for="comboBox">
Select a Game from combo box:
</label><br>
<select name="comboBox" id="comboBox">
<option value="cricket">Cricket</option>
<option value="khokho">Khokho 2</option>
<option value="kabaddi">Kabaddi 3</option>
<option value="hocky">Hocky</option>
</select>
<br><br>
<input type="hidden" name="hiddenField" id="hiddenField" value="hiddenValue">
<input type="submit" value="Submit">
</form>
</body>
</html>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$listBoxValue = $_POST['listBox'];
$comboBoxValue = $_POST['comboBox'];
$hiddenFieldValue = $_POST['hiddenField'];
echo "List Box Value: " . $listBoxValue . "<br>";
echo "Combo Box Value: " . $comboBoxValue . "<br>";
echo "Hidden Field Value: " . $hiddenFieldValue;
}
?>
OUTPUT :-
Exercise :-
1) Write a program to design a form using list box, combo box.
CODE :-
<html>
<head>
<title>
Form Design
</title>
</head>
<body>
<h2>
Form Design with PHP
</h2>
<form method="post" action="index.php">
<label for="listBox">
Select your favorite fruit:
</label>
<br>
<select name="listBox" id="listBox" multiple>
<option value="apple">Apple</option>
<option value="banana">Banana</option>
<option value="orange">Orange</option>
<option value="strawberry">Strawberry</option>
</select>
<br><br>
<label for="comboBox">
Select your favorite color:
</label>
<br>
<select name="comboBox" id="comboBox">
<option value="red">Red</option>
<option value="green">Green</option>
<option value="blue">Blue</option>
<option value="yellow">Yellow</option>
</select>
<br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$selectedFruit = $_POST['listBox'];
$selectedColor = $_POST['comboBox'];
echo "<p>Your favorite fruit is: " . ucfirst($selectedFruit) . "</p>";
echo "<p>Your favorite color is: " . ucfirst($selectedColor) . "</p>";
} else
{
echo "<p>No form submission detected.</p>";
}
?>
OUTPUT :-

You might also like