EXPERIMENT NUMBER 07.
A
DATE DAY MONT YEAR PHP PROGRAM TO DEMONSTRATE FORM
H ELEMENTS
OBJECTIVE (AIM) OF THE EXPERIMENT
To write a PHP program to demonstrate Form Elements (input elements).
FACILITIESREQUIRED
S.NO FACILITIES REQUIRED QUANTITY
1 System 1
2 O/S Windows / Linux OS
3 S/W name Any Browser
4 XAMPP server Any version
WEBLAYOUT
NAME
ROLL.NO
DEPT
BUTTON 1 BUTTON 2
PROCEDURE
Write code in Notepad.
Save the file with any name followed by filename .php extension.
Connect to XAMPP server.
Save the file in the XAMPP location.
In XAMPP location you should save it in htdocs.
Go to any browser and type localhost:8080/filename.php.
Input the details and record the output.
PROGRAM
ex7a.php
<html>
<head>
<title>HTML Forms Input and Display in PHP</title>
</head>
<body>
<style
type="text/css">
body {
font-family:
arial; size:
12px;
};
</style>
<?php
$display="";
$name = isset($_POST['name']) ? $_POST['name'] : '';
$rollno = isset($_POST['rollno']) ? $_POST['rollno'] : '';
$dept = isset($_POST['dept']) ? $_POST['dept'] : '';
if(isset($_POST['submit']))
{
$display .= "<h2> Display Results </h2>";
$display .= "Name : " .
($name) ."<br/>";
$display .= "Roll No:
".
($rollno)."<br/>";
$display .= "Dept: " .
($dept)."<br />";
}
if (isset($_POST['clear'])) {
$name ="";
$rollno ="";
$dept ="";
$display ="";
}
?>
<h2> HTML Forms Input and Display in PHP </h2>
<form method="post">
<p>Name: <input
type="text"
name="name"
value="<?php echo
$name; ?>"></p>
<p>Roll No: <input
type="text"
name="rollno" value="<?
php echo $rollno;
?>"></p>
<p>Dept: <input
type="text"
name="dept"
value="<?php echo
$dept; ?>"></p>
<input type="submit" name="submit" value="Submit" />
<input type="submit" name="clear" value="Clear" />
</form>
<?php
echo $display;
?>
</body>
</html>
OUTPUT:
RESULT: Thus we have created a PHP program to demonstrate Form Elements (input elements).