0% found this document useful (0 votes)
4 views4 pages

PHP B1

The document provides a PHP program for a student registration form that includes various input fields such as name, address, email, mobile, city, state, gender, hobbies, and blood group. Upon submission, the form data is processed and displayed in a structured table format on a new PHP page. The code includes HTML for the form and PHP for processing and displaying the submitted data.

Uploaded by

ananyakaranth10
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)
4 views4 pages

PHP B1

The document provides a PHP program for a student registration form that includes various input fields such as name, address, email, mobile, city, state, gender, hobbies, and blood group. Upon submission, the form data is processed and displayed in a structured table format on a new PHP page. The code includes HTML for the form and PHP for processing and displaying the submitted data.

Uploaded by

ananyakaranth10
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/ 4

PART-B IIIBCA

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>

<input type="text" id="last_name" name="last_name" required><br><br>


<label for="address">Address:</label><br>
<textarea id="address" name="address" required></textarea><br><br>
<label for="email">E-Mail:</label><br>
<input type="email" id="email" name="email" required><br><br>
<label for="mobile">Mobile:</label><br>

<input type="text" id="mobile" name="mobile" required><br><br>


<label for="city">City:</label><br>
<input type="text" id="city" name="city" required><br><br>
<label for="state">State:</label><br>
<input type="text" id="state" name="state" required><br><br>
<label>Gender:</label><br>

PHP and MySQL Lab Page 36


PART-B IIIBCA

<input type="radio" id="male" name="gender" value="Male" required>


<label for="male">Male</label><br>
<input type="radio" id="female" name="gender"value="Female" required>

<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>

PHP and MySQL Lab Page 37


PART-B IIIBCA

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'],

PHP and MySQL Lab Page 38


PART-B IIIBCA

"Mobile" => $_POST['mobile'],


"City" => $_POST['city'],
"State" => $_POST['state'],

"Gender" => $_POST['gender'],


"Hobbies" => isset($_POST['hobbies']) ?
implode(", ", $_POST['hobbies']) : "",
"Blood Group" => $_POST['blood_group']
);
foreach ($fields as $field => $value) {
echo

"<tr><td>$field</td><td>$value</td></tr>";
}
echo "</table>"; } ?>
</body>
</html>
Output:

PHP and MySQL Lab Page 39

You might also like