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:

<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>
<p align="center">
<input type="submit">
<input type="Reset">


The output of the above code:


First name:
Last name:

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:

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

echo $_POST["fname"];

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


After Executing above two file the output looks like below:

Welcome Humayunkabir
You are 20 years old.

Related Post: