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

WBP22202A0023PR10

Uploaded by

guyn9074
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

WBP22202A0023PR10

Uploaded by

guyn9074
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

IF6IA WBP

DEPARTMENT OF INFORMATION TECHNOLOGY

Subject: Web based Application Development Subject Code: 22619


using PHP
Semester: 6th Course: IF6IA
Laboratory No: L001 Name of Teacher: Chetashri Bhusari
Name of Student: Prajwal Patekar Roll ID: 2220A0023

Experiment No: 10
Title of Experiment Design a web page using following form controls:
a.Text box, b. Radio button, c. Check box, d. Buttons

☆ Practical Related Questions


1. Write a use and syntax of following controls in PHP.
a. Textbox b. Radio button c. Check box d. Buttons
Ans: a. Textbox
 Use: To accept single-line input from the user (e.g., name, email).

 Syntax:

<form method="post">

Name: <input type="text" name="username"><br>

<input type="submit" name="submit" value="Submit">

</form>

<?php

if (isset($_POST['submit'])) {

$name = $_POST['username'];

echo "Hello, " . htmlspecialchars($name);

?>

b. Radio Button

 Use: To allow the user to select only one option from multiple choices.

 Syntax:

<form method="post">
22202A0023 Prajwal Patekar
IF6IA WBP

Gender:

<input type="radio" name="gender" value="Male"> Male

<input type="radio" name="gender" value="Female"> Female<br>

<input type="submit" name="submit" value="Submit">

</form>

<?php

if (isset($_POST['submit'])) {

$gender = $_POST['gender'];

echo "Selected Gender: " . $gender;

?>

c. Checkbox

 Use: To allow the user to select multiple options from a list.

 Syntax:

<form method="post">

Hobbies:<br>

<input type="checkbox" name="hobbies[]" value="Reading"> Reading<br>

<input type="checkbox" name="hobbies[]" value="Traveling"> Traveling<br>

<input type="checkbox" name="hobbies[]" value="Gaming"> Gaming<br>

<input type="submit" name="submit" value="Submit">

</form>

<?php

if (isset($_POST['submit'])) {

if (!empty($_POST['hobbies'])) {

$hobbies = $_POST['hobbies'];

echo "Your hobbies are: " . implode(", ", $hobbies);

} else {

echo "No hobbies selected.";

}
22202A0023 Prajwal Patekar
IF6IA WBP

?>

d. Button

 Use: To submit the form or trigger an action.

 Syntax:

<form method="post">

<input type="submit" name="submit" value="Click Me">

</form>

<?php

if (isset($_POST['submit'])) {

echo "Button clicked!";

?>

☆ Exercise

1. Develop web page and do validation using control text box, radio button,
check box and button.
Ans:
Stud.html
<html>
<body>
<form action="stud.php" method="post">
Name: <input type="text" name="name" id="name">
Address: <input type="text" name="address" id="address">
<label>Select your Gender:</label><br/>
<input type="radio" name="gender" value="male" checked> Male<br/>
<input type="radio" name="gender" value="female"> Female<br/>
<input type="submit" value="submit">
</form>
</body>

22202A0023 Prajwal Patekar


IF6IA WBP

</html>

Stud.php
<html>
<body>
GENERAL INFORMATION
<br> <br> <br>
Welcome: <?php echo $_POST["name"]; ?>!
<br>
Your address is: <?php echo $_POST["address"]; ?>
<?php
if(isset($_POST["gender"])){
echo "<p>Gender : " . $_POST["gender"] . "</p>";
}
?>
</body>
</html>

Output:

22202A0023 Prajwal Patekar


IF6IA WBP

22202A0023 Prajwal Patekar

You might also like