Introduction

We are describing Form handling in PHP. The HTML form attribute is aoutomatically available in your PHP script.

Example


Create a file named "Form.tpl".

<html>

<head>

<title>send mail in php</title>

<style type="text/css">

li {list-style-type: none;

font-size: 16pt;

margin-bottom: 7px;

}<br>

.survey

{

margin: auto;

padding-top: 10px;

padding-bottom: 10px;

width: 400px;

background : #D8F1F8;

border: 1px soild silver;

}

.survey h2

{

margin-left: 38px;

}

input

{

font-size: 20pt;

}

input:focus, textarea:focus

{

background-color: lightyellow;

}

input submit {

font-size: 12pt;

}

</style>

</head>

<body bgcolor="#FFFFCC">

<div class="survey">

<h2>Survey Form </h2>

<ul>

<form name="survey" action="action.php" method="POST" >

<li>Name:</li><li><input type="text" name="name" /></li>

<li>Date:</li><li><input type="text" name="date" /></li>

<li>email:</li><li><input type="text" name="email" /></li>

<li><input type="submit" /></li>

</form>

</ul>

</div>

</body>

</html>

Next, the PHP script to save (action.php) handles the form data using $_POST.

<html>

<h1>view plainprint?</h1>

<?php

$name = $_POST['name'] ;

$date = $_POST['date'] ;

$email = $_POST['email'];

echo "<ul><li>".$name."</li><li>".$date."</li><li>".$email."</li></ul>";

?>

<html>

Output

Form-Handling-in-PHP21.jpg

Form-Handling-in-PHP2.jpg

Form-Handling-in-PHP3.jpg