Home >>PHP Tutorial >PHP Form

PHP Form

PHP Form Example

PHP form is used to take input from users. in PHP if you want to take input from keyboard and display the output according to input, in that case you have to use html form. html form's have a property : form method in which you have to set either get or post method. To illustrate, consider the following  Web form(choose.php) which asks you to select a brand of automobile and enter your desired color.


Save it as Choose.php

<title>form method</title>



<form method="post">

<h2>Select Your car</h2>

<table border="1" align="center">


<td>Select Your car</td>


<Selct name="selType">

<option value="porsche 911">Porsche 911</option>

<option value="Volkswagen Beetle">Volkswagen Beetle</option>

<option value="Ford Taurus">Ford Taurus</option>






<td><input type="text" name="txtColor"/>




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







PHP Script

echo "<font color='blue'>Your $color $type is ready. safe driving! </font>";


Output Your blue Porshe 911 is ready. safe driving! Select your car Color

In the given above example: First create a static page using HTML . Form first part is a drop down box from where user has to select the option, 2nd part is a text box in which user enter the color , after entered the value user click on button to display the output. output displays lik Your blue Porshe 911 is ready. safe driving!

No Sidebar ads