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?
You can send multiple values by adding []
to the end of the name. It will convert into an array on php side.
name="language[]"