PHP Judging form check box checked status complete Example _php tutorial

Source: Internet
Author: User
check boxes are frequently used in Web forms, so how do you use PHP to determine which checkboxes in a submitted form are selected and read the data in them?

First create a form: form.html
Copy the Code code as follows:


Then create a program that processes the form: checkbox.php
Copy the Code code as follows: <?php
$a =$_post["s"];
Print_r ($a);
?>


This can be shown in the form of arrays, which are selected. Display results similar to: Array ([0]=7 [1]=15]

However, the above program is only used to show whether the check box is normal, if you remove all the data in the array, you need to use the loop.

So the program is further modified to: checkbox.php
Copy the Code code as follows:
<?php
$a =$_post["s"];
for ($i =0; $i<>
{
echo "Options". $a [$i]. " is selected
";
}
?>


The result of this execution is similar to the following:
Copy the Code code as follows: Option 3 is selected
Option 15 is selected

I believe the next step is more convenient to execute other statements.

http://www.bkjia.com/PHPjc/824834.html www.bkjia.com true http://www.bkjia.com/PHPjc/824834.html techarticle check boxes are frequently used in Web forms, so how do you use PHP to determine which checkboxes in a submitted form are selected and read the data in them? First create a form: form.html ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.