データベースやセッションを含まない私のコードは完璧な結果をもたらします
<!DOCTYPE html>
<?php
if(isset($_GET["engine"]))
{
if($_GET["engine"]=="google")
header("Location:http://www.google.com/search?q=".$_GET["q"]);
elseif($_GET["engine"]=="yahoo")
header("Location:http://search.yahoo.com/search?q=".$_GET["q"]);
if($_GET["engine"]=="bing")
header("Location:http://www.bing.com/search?q=".$_GET["q"]);
}
?>
<html>
<head>
<title>Fake search</title>
</head>
<body>
<form action="fakeSearch.php" method="GET">
<input type="text" name="q" value=""/><br/>
Google <input type="radio" name="engine" value="google"/><br/>
Yahoo <input type="radio" name="engine" value="yahoo"/><br/>
Bing <input type="radio" name="engine" value="bing"/><br/>
<input type="submit"/>
</form>
</body>
</html>
しかし、ログインページを作成し、セッション変数を使用して上記と同じコードを持つhome.phpにリダイレクトすると、オブジェクトが見つかりませんというエラーが表示されます!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7
これがコードです
<?php
session_start();
if(isset($_SESSION["authenticated"]))
{
if($_SESSION["authenticated"]==TRUE)
?>
<!DOCTYPE html>
<html>
<head><title>Home</title></head>
<body>
<a href="logout.php">Logout</a>
<?php
if(isset($_GET["engine"]))
{
if($_GET["engine"]=="google")
header("Location:http://www.google.com/search?q=".$_GET["q"]);
elseif($_GET["engine"]=="yahoo")
header("Location:http://search.yahoo.com/search?q=".$_GET["q"]);
if($_GET["engine"]=="bing")
header("Location:http://www.bing.com/search?q=".$_GET["q"]);
}
?>
<form action="fakeSearch.php" method="GET">
<input type="text" name="q" value=""/><br/>
Google <input type="radio" name="engine" value="google"/><br/>
Yahoo <input type="radio" name="engine" value="yahoo"/><br/>
Bing <input type="radio" name="engine" value="bing"/><br/>
<input type="submit"/>
</form>
</body>
</html>
<?php }
else{
header("Location:login.php.");
}?>