<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>ボタンを使いたい</title>
</head>
<body>
<?php
echo '<p>結果:</p>';
echo '<p>ラジオボタンの値:</p>';
echo h(@$_POST['example1']);
echo '<p>テキストボックスの値:</p>';
echo h(@$_POST['example2']);
echo '<hr />';
function h($string) {
return htmlspecialchars($string, ENT_QUOTES);
}
?>
<form method="post" action="">
<p>ラジオボタン</p>
<input type="radio" name="example1" value="男" />男
<input type="radio" name="example1" value="女" />女
<p>テキストボックス</p>
<input type="text" name="example2" size="30" />
<br />
<input type="submit" value="送信する" />
<input type="reset" value="リセット" />
</form>
</body>
</html>