0

Here is index.php

<!doctype html>
<html>
<head>
</head>
<body>
    <form action="process.php" method="post">
        <input type="checkbox" name="language" value="C" />:C
        <input type="checkbox" name="language" value="C++"/>:C++
        <input type="checkbox" name="language" value="java"/>:JAVA
        <input type="checkbox" name="language" value="python"/>:PYTHON
        <input type="checkbox" name="language" value="none"/>:None
        <br/>
        <input type="submit" value="submit" />
    </form>
</body>
</html>

Here is my process.php

<!doctype html>
<html>
<head></head>
<body>
    <pre>
        <?php
        print_r($_POST);
        ?>
    </pre>
</body>
</html>

Both files are in same folder. In these php pages i am trying to show the content of data send through index.php form.
But it only shows the last clicked checkbox. For example if i have checked C++ and JAVA then it will only show JAVA all preceding will be kicked off. Since checkbox are made for multiple checks why not it just show it as array(values)?
I want to know how to get multiple values for single name?

1

1 Answer 1

3

You can send multiple values by adding [] to the end of the name. It will convert into an array on php side.

name="language[]"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.