Getting checkbox values on submit

 
 
 
 
 
 
<form action="third.php" method="get">
Red<input type="checkbox" name="color[]" id="color" value="red">
Green<input type="checkbox" name="color[]" id="color" value="green">
Blue<input type="checkbox" name="color[]" id="color" value="blue">
Cyan<input type="checkbox" name="color[]" id="color" value="cyan">
Magenta<input type="checkbox" name="color[]" id="color" value="Magenta">
Yellow<input type="checkbox" name="color[]" id="color" value="yellow">
Black<input type="checkbox" name="color[]" id="color" value="black">
<input type="submit" value="submit">
</form>
 
third.php
 
 
<?php

$name = $_GET['color'];

// optional
// echo "You chose the following color(s): <br>";

foreach ($name as $color){
echo $color."<br />";

}

?> 

Comments

Popular posts from this blog

PHP Ajax Login Validation Tutorial

Real-Time Web Interface to MQTT using Socket.io and Node.js

New User Registration With Email Verification Using PHP and Mysqli