POSTの利用
<html>
<head>
<meta charset="UTF-8">
<title>パスワード(post)</title>
</head>
<body>
<form action="test.php" method="post">
<label for="name">お名前:</label>
<input type="text" name="name" size="50" value="">
<br>
<label for="pass">パスワード:</label>
<input type="password" size="50" name="pass" value>
<input type="submit" value="送信">
</form>
</body>
</html>
<?php
var_dump($_POST['pass']);
getの利用
<html>
<head>
<meta charset="UTF-8">
<title>無題ドキュメント</title>
</head>
<body>
<a href="#">getのテスト</a>
<form action="test2.php" method="get">
<label for="name">お名前:</label>
<input type="text" name="name" size="50" value="">
<br>
<label for="pass">パスワード:</label>
<input type="password" size="50" name="pass" value>
<input type="submit" value="送信">
</form>
</body>
</html>
<?php
var_dump($_POST['pass']);
実行結果
- 実行結果はpostでもgetでも結果は同じ
- getの方はURLに入力情報が出てしまう。
http://localhost/php/20140416/test2.php?name=rensyu&pass=rensyu1234
その他memo
<html>
<head>
<meta charset="UTF-8">
<title>無題ドキュメント</title>
</head>
<body>
<a href="http://localhost/php/20140416/test2.php?name=rensyu&pass=rensyu1234">getのテスト</a>
<form action="test2.php" method="get">
<label for="name">お名前:</label>
<input type="text" name="name" size="50" value="">
<br>
<label for="pass">パスワード:</label>
<input type="password" size="50" name="pass" value>
<input type="submit" value="送信">
</form>
</body>
</html>
- リンクタグにget送信の実行結果のURLを埋め込み実行。
- 実行結果後のURLに入っている数字を変更しても値が返される。