knowledgediarybd.com

Your Virtual Knowledge Campus

PHP Forms tutorial

php forms examplePHP Forms tutorial.PHP Forms are used in HTML forms by two major variable

Name: $_GET and $_POST.By using $_GET & $_POST We can retrieve a number of data form HTML forms.

Dear learner here you can how to create a HTML Forms

& how to it work with proper example.

Example of HTML Forms:

An example below contains an HTML form which is also known as  php contact form with three input fields First_Name,Last_Name ,Age, and

a submit button:

<html>
<body>
<p style="text-align: center;"><form action="Example.php" method="post"></p>
<p style="text-align: center;"><p align="center"> HTML FORMS</p>
<p align="center">
<table align="center">
<tr><td>First name:</td> <td><input type=”text” name=”firstname”/><br></td></tr>
<tr><td>Last name: </td> <td><input type=”text” name=”lastname”/><br></td></tr>
<tr><td>Age: </td> <td><input name=”age” type=”text” id=”age” /><br></td></tr>
<tr><td>E-mail: </td> <td><input name=”e-mail” type=”text” id=”e-mail”/><br></td></tr>
<tr><td>Password: </td> <td><input name=”password” type=”text” id=”password” /></td></tr>
</table>
</p>
<p align="center">
<input type="submit">
<input type="Reset">

</p>
</body>
</html>

The output of the above code:

HTML FORMS

First name:
Last name:
Age:
E-mail:
Password:


After fill up the above form when we click submit button then $_POST variable  work on file name: Example.php

The Example.php file looks like below:

<html>
<head>
<title>Action of HTLM Form BY PHP</title>
</head>

<body>
Welcome
<?php
echo $_POST["fname"];
?>

<?php
echo $_POST["lname"];
?>
<br>
You are
<?php echo $_POST["age"];
?>
years old.

</body>
</html>

After Executing above two file the output looks like below:

Welcome Humayunkabir
You are 20 years old.

Related Post:

knowledgediarybd.com © 2017
shares