PHP HTML Form checkbox Example

PHP HTML Form checkbox Example

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



      echo "<h3>Your submitted form data as bellow</h3>";

      echo "Your Name : {$_POST['FullName']}</br>";
      echo "You Like : {$_POST['YourChoice']}</br>";

      echo "<hr>";


<h3>PHP HTML Form checkbox Example</h3>

<form name="UserInformationForm" method="POST" action="#">
      Enter Your Full Name :
      <input name="FullName" type="text" value="<?php echo $_POST['FullName']; ?>"><br/><br/>
      I Like :
      <input name="YourChoice" type="checkbox" value="fish" <?php if($_POST['YourChoice']=="fish") echo "checked=checked"; ?> > Fish
      <input name="YourChoice" type="checkbox" value="meat" <?php if($_POST['YourChoice']=="meat") echo "checked=checked"; ?> > Meat
      <input name="YourChoice" type="checkbox" value="vegetable" <?php if($_POST['YourChoice']=="vegetable") echo "checked=checked"; ?> > Vegetable
      <input name="BtnSubmit" type="submit" value="Submit">

Fire-up your favorite browser to see the effect of a blank HTML form with checkbox in PHP "http://localhost/blog/php-html-form-checkbox-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-checkbox-example.php". Browser output should look like as follows:


Related Tutorial Examples

  1. HTML Form Example in PHP
  2. PHP HTML Form textarea Example
  3. PHP HTML Form select box Example
  4. 20 steps to make CakePHP Blog Project
  6. MySQL IF() Function NULL Value Example
  7. MySQL NULL to zero value Example
  8. MySQL Stored Procedure: Variable Example
  9. UNIX Command Example: mv - Move file(s) or directory(ies)
  10. PERL Example: Binary Hexadecimal Octal to Decimal Conversion in PERL

1 comment:

leave your comments here..