| 第11週-Form-Checkbox<?php $command=$_POST["command"]; if ($command=="") { echo "<html><body><center> <form method=post action=''> 第一題: <input type=checkbox name=choice1[] value=1>choice 1 <input type=checkbox name=choice1[] value=2>choice 2 <input type=checkbox name=choice1[] value=3>choice 3 <input type=checkbox name=choice1[] value=4>choice 4 <input type=checkbox name=choice1[] value=5>choice 5<br> <input type=submit name=command value=送出> <input type=reset name=command value=清除> </form></center></body></html>"; } if ($command=="送出") { $choice1=$_POST["choice1"]; $cnt1=count($choice1); if ($cnt1!=1) { echo "第一題必須選一個選項"; die(); } echo "第一題答案:" . $choice1[0]."<br>"; } ?> 作業 設計滿意度問卷五題 單選 必選 如果未選或選項大於1個 丟出錯誤訊息 例如 1. 對學校的滿意度 非常滿意 滿意 普通 不滿意 非常不滿意 | |