PHP HTML Form select box Example

PHP HTML Form select box Example

make a file “php-html-form-select-box-example.php" then copy & paste blow code.



      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>
      <input name="BtnSubmit" type="submit" value="Submit">

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

  1. PHP HTML Form checkbox Example
  2. PHP HTML Form radio button Example
  3. PHP HTML Form textarea Example
  4. PHP HTML Form Input Example
  5. MySQL NULLIF() Nested Function Example
  6. MySQL coalesce() Function Example
  7. MySQL Stored Procedure Function: Making hello world Function using aliase Example
  8. 20 steps to make CakePHP Blog Project
  9. PERL Example: Use of Arrays in PERL
  10. UNIX Command Example: File Last Modification Information

No comments:

Post a Comment

leave your comments here..