password(パスワード)の利用

POSTの利用
  • 「index.php
<!doctype html>
<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>
  • 「test.php
<?php
var_dump($_POST['pass']);
getの利用
  • 「index.php
<!doctype html>
<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>
  • 「test.php
<?php
var_dump($_POST['pass']);
実行結果
  1. 実行結果はpostでもgetでも結果は同じ
  2. getの方はURLに入力情報が出てしまう。
http://localhost/php/20140416/test2.php?name=rensyu&pass=rensyu1234
その他memo
<!doctype html>
<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>
  1. リンクタグにget送信の実行結果のURLを埋め込み実行。
  2. 実行結果後のURLに入っている数字を変更しても値が返される。