PHP HTML Form


 

PHP HTML Form

In the current tutorial we will study about PHP and HTML form, we will see how to send HTML . We will combine one html file and PHP file to display data. It is a very common application and you can further modify the code using some validation checking etc.

In the current tutorial we will study about PHP and HTML form, we will see how to send HTML . We will combine one html file and PHP file to display data. It is a very common application and you can further modify the code using some validation checking etc.

PHP & HTML Form:

In the current tutorial we will study about PHP and HTML form, we will see how to send HTML . We will combine one html file and PHP file to display the contents in PHP file. Whenever we click the submit button, it redirects to the PHP file and PHP file displays the data. You can modify the coding by your own, by putting some validation using JavaScript file.

We will take user's name and city from a html file and display those information on other PHP file.

Example :

PHP file:

<?php

$name=$_GET['name'];

$country=$_GET['country'];

echo "Name is:".$name." and country is:".$country;

?>

HTML file:

<HTML>

<BODY>

<form method="get" action="<?php $_SERVER['PHP_SELF']?>">

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

Country:<input type="text" name="country"/><br/>

<input type="submit" value="Submit"/>

</form>

</BODY>

</HTML>

 

Output:

 

Exaplanation:

In the above HTML file we create a HTML form and send the data to PHP file get method. 

Ads