我的不涉及任何数据库或会话的代码给出了完美的结果
<!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.");
}?>