PHP HTML Form select box Example
make a file “php-html-form-select-box-example.php" then copy & paste blow code.
php-html-form-select-box-example.php
<?php
if(isset($_POST['BtnSubmit']))
{
echo "<h3>Your submitted form data as bellow</h3>";
echo "Your Name : {$_POST['FullName']}</br>";
echo "You Country : {$_POST['YourCountry']}</br>";
echo "<hr>";
}
?>
<h3>PHP HTML Form select box Example</h3>
<form name="UserInformationForm" method="POST" action="#">
Enter Your Full Name :
<input name="FullName" type="text" value="<?php echo $_POST['FullName']; ?>"><br/><br/>
My Country :
<select name="YourCountry">
<option value=""></option>
<option value="Argentina" <?php if($_POST['YourCountry']=="Argentina") echo "selected=selected"; ?>>Argentina</option>
<option value="Bangladesh" <?php if($_POST['YourCountry']=="Bangladesh") echo "selected=selected"; ?>>Bangladesh</option>
<option value="Germany" <?php if($_POST['YourCountry']=="Germany") echo "selected=selected"; ?>>Germany</option>
</select>
<br/><br/>
<input name="BtnSubmit" type="submit" value="Submit">
</form>
Fire-up your favorite browser to see the effect of a blank HTML form with select box in PHP "http://localhost/blog/php-html-form-select-box-example.php". Browser output should look like as follows:
Now fill-up the HTML form and get submitted data in PHP "http://localhost/blog/php-html-form-select-box-example.php". Browser output should look like as follows:
Related Tutorial Examples
- PHP HTML Form checkbox Example
- PHP HTML Form radio button Example
- PHP HTML Form textarea Example
- PHP HTML Form Input Example
- MySQL NULLIF() Nested Function Example
- MySQL coalesce() Function Example
- MySQL Stored Procedure Function: Making hello world Function using aliase Example
- 20 steps to make CakePHP Blog Project
- PERL Example: Use of Arrays in PERL
- UNIX Command Example: File Last Modification Information


No comments:
Post a Comment
leave your comments here..