[Exclusively for beginners] PHP gets checkbox value

<!DOCTYPE html>
<html>
<head></head>
<body>
<form method=post action="" name="form1">
<input type="checkbox" name="t1[]" value="篮球">篮球<br>
<input type="checkbox" name="t1[]" value="足球">足球<br>
<input type="checkbox" name="t1[]" value="乒乓球">乒乓球<br>
<input type="checkbox" name="t1[]" value="排球">排球<br>
<input type="submit" name="sumbmit">
</form>
</body>
</html>

<?PHP  

    if(!empty($_POST["t1"])){  
        
        $array = $_POST["t1"];  
        $size = count($array);  
 
        for($i=0; $i< $size; $i++){  
            echo $array[$i]."<br>";
        } 
        }  

Supongo que te gusta

Origin blog.csdn.net/zgscwxd/article/details/135418683
Recomendado
Clasificación