Skip to main content

Practical-06

Write a PHP program to read the employee detail using form component.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") { // if the form is submitted then only the below code will run...

// Retrieve the form data by using the element's name attributes value as key...
$employee_name = $_POST['employee_name']; // $_POST is a superglobal variable...
$employee_email = $_POST['employee_email'];
$employee_department = $_POST['employee_department'];

// Display the results
echo "<h2>Employee Details Submitted:</h2>";
echo "<p>Name: " . $employee_name . "</p>";
echo "<p>Email: " . $employee_email . "</p>";
echo "<p>Department: " . $employee_department . "</p>";
}
?>

<html>

<head>
<title>Employee Detail Form</title>
</head>

<body>

<form action="" method="post">
<label for="employee_name">Name:</label><br>
<input type="text" id="employee_name" name="employee_name" ><br>

<label for="employee_email">Email:</label><br>
<input type="email" id="employee_email" name="employee_email" ><br>

<label for="employee_department">Department:</label><br>
<input type="text" id="employee_department" name="employee_department" ><br><br>

<input type="submit" value="Submit">
</form>

</body>

</html>