| 
                         在浏览器的错误信息中可以看到 
  
错误信息表明了,不允许进行跨域。 
X-Frame-Options: ALLOW-FROM http://www.site.com 
X-Frame-Options: ALLOW_FROM选项,表示该页面可以在指定来源的 frame 中展示,该选项只适用于IE,Firefox浏览器。 
首先打开home.php文件添加如下代码 
- header(“X-Frame-Options: ALLOW-FROM http://localhost”);
 
 
 
修改后代码如下: 
<?php
session_start();
session_regenerate_id();
header("X-Frame-Options: ALLOW-FROM http://localhost");
if(!isset($_SESSION['admin_loggedin']))
{
    header('Location: index.php');
}
if(isset($_GET['search']))
{
    if(!empty($_GET['search']))
    {
        $text = $_GET['search'];
    }
    else
    {
        $text = "No text Entered";
    }
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Admin Home</title>
        <link rel="stylesheet" href="styles.css">
    </head>
    <body>
 
         <div id="home"><center>
        </br><legend><text id=text><text id="text2">Welcome to Dashboard...</text> </br></br> You are logged in as:  <?php echo $_SESSION['admin_loggedin']; ?>  <a href="logout.php">[logout]</a></text></legend></br>
        <form action="" method="GET">
            <div id="search">
            <text id="text">Search Values</text><input type="text" name="search" id="textbox"> </br></br>
 
             <input type="submit" value="Search" name="Search" id="but"/>
 
             <div id="error"><text id="text2">You Entered:</text><?php echo $text; ?></div>
 
             </div>
        </form></center>
    </div>
 
     </body>
</html>
 
退出网页,重新登录,观察HTTP头 
  
如果我们现在尝试从同一个服务器加载iframe,网页不会出现任何错误 
  
这是因为服务器允许加载http://localhost 这个地址 
现在我们修改HTTP头,再加载 
在home.php文件中添加 
- header(“X-Frame-Options: ALLOW-FROM http://www.androidpentesting.com”);
 
 
 
修改后代码如下 
<?php
session_start();
session_regenerate_id();
header("X-Frame-Options: ALLOW-FROM http://www.androidpentesting.com");
if(!isset($_SESSION['admin_loggedin']))
{
    header('Location: index.php');
}
if(isset($_GET['search']))
{
    if(!empty($_GET['search']))
    {
        $text = $_GET['search'];
    }
    else
    {
        $text = "No text Entered";
    }
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Admin Home</title>
        <link rel="stylesheet" href="styles.css">
    </head>
    <body>
 
         <div id="home"><center>
        </br><legend><text id=text><text id="text2">Welcome to Dashboard...</text> </br></br> You are logged in as: <?php echo $_SESSION['admin_loggedin']; ?>  <a href="logout.php">[logout]</a></text></legend></br>
        <form action="" method="GET">
            <div id="search">
            <text id="text">Search Values</text><input type="text" name="search" id="textbox"></br></br>
 
             <input type="submit" value="Search" name="Search" id="but"/>
 
             <div id="error"><text id="text2">You Entered:</text><?php echo $text; ?></div>
 
             </div>
        </form></center>
    </div>
 
     </body>
</html>
 
以下为抓包获取的HTTP头信息 
  
                        (编辑:滁州站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |