Php practical no.10 outputs
Php practical no.10 outputs
10
Outputs
Q.1 Write a program to design a registration form using textbox, radio button,
checkbox and button.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Form</title>
</head> Output
<body>
Registration Details:
Gender: Male
<form method="POST" action="">
<!-- Textbox for name --> Terms: Agreed
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br><br>
<?php
if (isset($_POST['submit'])) {
// Capture form data
$name = $_POST['name'];
$gender = $_POST['gender'];
$terms = isset($_POST['terms']) ? "Agreed" : "Not Agreed";
Q. Develop web page and do validation using control text box, radio button , check
box and button.
Ans.
<?php
$nameErr = $genderErr = $hobbyErr = "";
$name = $gender = $hobby = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Name validation
if (empty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["name"]);
}
PRACTICAL No.10
Outputs
// Gender validation
if (empty($_POST["gender"])) {
$genderErr = "Gender is required";
} else {
$gender = test_input($_POST["gender"]);
}
// Hobby validation
if (empty($_POST["hobby"])) {
$hobbyErr = "At least one hobby must be selected";
} else {
$hobby = test_input($_POST["hobby"]);
}
}
<?php
PRACTICAL No.10
Outputs
</body>
</html>