ログインしていないときは、このページのURLをブラウザに入力するとフォームが表示されます。ログインしていない場合は、HTMLを表示したくないというメッセージが表示されます。ログインする必要があるだけのメッセージです。他のページで同じセッションコードを使用していますが、動作しますが、 '未定義インデックス'ビット刺激。何か案は?PHPセッションが開始しない
<?php
session_start();
if ($_SESSION['first_name']&& $_SESSION['username'])
echo "Welcome ".$_SESSION['first_name']."<br><a href='login/logged_out.php'>log
out</a>";
else
die("You must be logged in. Click <a href='login/login_page.php'>here</a> to log
in.");
?>
<html>
<head>
</head>
<body>
<form id="1" class="rounded" action="test4.php" method="post"/>
<input type="submit" name="submit" class="button" value="5" />
<form id="2" class="rounded" action="test4.php" method="post"/>
<input type="submit" name="submit" class="button" value="6" />
<form id="3" class="rounded" action="test4.php" method="post"/>
<input type="submit" name="submit" class="button" value="7" />
<form id="4" class="rounded" action="test4.php" method="post"/>
<input type="submit" name="submit" class="button" value="8" />
<form id="5" class="rounded" action="test4.php" method="post"/>
<input type="submit" name="submit" class="button" value="9" />
<form id="6" class="rounded" action="test4.php" method="post"/>
<input type="submit" name="submit" class="button" value="10" />
</form>
</body>
</html>
「ログインしていますか? セッションを処理する際に最もよくある間違いの1つは、session_write_close()を呼び出す前にリダイレクトされることです。 –
[PHP: "Notice:未定義変数"と "Notice:未定義インデックス"](http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – animuson