PHPの教科書3 ラジオボタン
ラジオボタンで値を渡す
http://felica.boy.jp/textbook/lecture1-1-5.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>よく分かるPHPの教科書</title> </head> <body> <form action="lecture1-1-5.php" method="post"> <dl> <dt>性別:</dt> <dd> <!-- ラジオボタンで送られるデータはvalue属性 --> <input id="gender_male" type="radio" name="gender" value="male"> <label for="gender_male">男性</label> <input id="gender_female" type="radio" name="gender" value="female"> <label for="gender_female">女性</label> </dd> </dl> <input type="submit" value="送信する"> </form> </body> </html>
<?php //ラジオボタンでもhtmlspecialcharsは必要 print('性別:'.htmlspecialchars($_POST['gender'],ENT_QUOTES)); ?>