PHP B1
PHP B1
1. PHP program to implement student registration form using Labels, Text Boxes, Text Area,
Checkbox, Radio Buttons, Select and Submit button. (First Name, Last Name, Address, E-Mail,
Mobile, City, State, Gender, Hobbies, Blood Group). Display user inserted value in a new PHP
page in a neat format.
registration.php
<!DOCTYPE html>
<html>
<head>
<title>Student Registration Form</title>
</head>
<body>
<h2>Student Registration Form</h2>
<form method="post" action="process_registrationb1.php">
<label for="first_name">First Name:</label><br>
<input type="text" id="first_name" name="first_name" required><br><br>
<label for="last_name">Last Name:</label><br>
<label for="female">Female</label><br><br>
<label>Hobbies:</label><br>
<input type="checkbox" id="hobby1" name="hobbies[]" value="Reading">
<label for="hobby1">Reading</label><br>
<input type="checkbox" id="hobby2" name="hobbies[]" value="Sports">
<label for="hobby2">Sports</label><br>
<input type="checkbox" id="hobby3" name="hobbies[]" value="Music">
<label for="hobby3">Music</label><br><br>
<label for="blood_group">Blood Group:</label><br>
<select id="blood_group" name="blood_group" required>
<option value="">Select</option>
<option value="A+">A+</option>
<option value="A-">A-</option>
<option value="B+">B+</option>
<option value="B-">B-</option>
<option value="AB+">AB+</option>
<option value="AB-">AB-</option>
<option value="O+">O+</option>
<option value="O-">O-</option>
</select><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Process_registrationb1.php
<!DOCTYPE html>
<html>
<head>
<title>Registration Details</title>
<style>
table {
border-collapse: collapse;
width: 50%; }
th, td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px; }
</style>
</head>
<body>
<h2>Registration Details</h2>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
echo "<table>";
echo "<tr><th>Field</th><th>Value</th></tr>";
$fields = array(
"First Name" => $_POST['first_name'],
"Last Name" => $_POST['last_name'],
"Address" => $_POST['address'],
"E-Mail" => $_POST['email'],
"<tr><td>$field</td><td>$value</td></tr>";
}
echo "</table>"; } ?>
</body>
</html>
Output: