Practical - 8 IWD

 

Aim: Create a web page using a form to collect employee information

File Name: employee_form.php

<!DOCTYPE html> <html> <head> <title>Employee Information Form</title> </head> <body> <h2>Employee Information Form</h2> <form method="post" action=""> Employee ID: <input type="text" name="empid"><br><br> Employee Name: <input type="text" name="empname"><br><br> Department: <input type="text" name="dept"><br><br> Salary: <input type="text" name="salary"><br><br> <input type="submit" name="submit" value="Submit"> </form> <?php if (isset($_POST['submit'])) { echo "<h3>Employee Details</h3>"; echo "Employee ID: " . $_POST['empid'] . "<br>"; echo "Employee Name: " . $_POST['empname'] . "<br>"; echo "Department: " . $_POST['dept'] . "<br>"; echo "Salary: " . $_POST['salary'] . "<br>"; } ?> </body> </html>

Explanation (for viva):

  • HTML form collects employee data

  • POST method is used

  • PHP displays submitted data using $_POST

Comments

Popular posts from this blog

Unit I - Introduction to PHP

Practical - 1 IWD

Practical - 10 IWD