这是子页地址
http://127.0.0.1/hotel_index/index_bc.htm
这是主页
http://127.0.0.1/hotel_index/
希望实现,当输入任何子页面地址,都必须连接登录主页面
我的子页面是个框架index_bc.htm
主页面是个php我现在登陆页写$_SESSION['FORMINDEX'] = "yes";然后在index_bc.htm中写
session_start();
if(!isset($_SESSION['FORMINDEX'])){
  header("location: index.php");
}
可是还是不行,请大侠帮忙

解决方案 »

  1.   

    你在html文件里面写php当然不行,你要把index_bc.htm重命名为index_bc.php
      

  2.   

    还是不行啊
    登陆页
    <?php
    session_start();
    include("lianjie.php");
    ?>
    <?php
    $_SESSION['FORMINDEX'] = "yes";
    ?><!--***************登录页面***************-->
    <link href="CSS/css.css" rel="stylesheet" type="text/css">
    <body >
    <table width="800px"align="center"  >
    <tr>
    <td align="right" valign="top"><img src="img/logo01.jpg" align="right"></td>
    </tr>
    <tr><td height="252" colspan="3">
      <form name="form1" method="post" action="" onsubmit="return Checkform();"  style=" text-align:center; ">
            <table width="100%" height="300"  style="background-image:url(img/background.jpg);">
              <tr>
                <td align="center" colspan="2">
                  <table border="0" cellspacing="0" cellpadding="1" align="center">
        <tr>
                <td colspan="2" align="center" height="50px"><font color="#FFFFFF" face="华文宋体" size="+1">用户登录</font></td>
                  </tr>
        <tr>
                      <td height="30">
                      <div align="right" style="color:#FFFFFF; font-size:13px; height:10px;">用户名:</div></td>
                      <td align="left">
                        <input type="text" name="user_login" size="20" maxlength="16"  style="border-color:#666666;">
                      </td>
                    </tr>
                    <tr><td height="30">
                        <div align="right" style="color:#FFFFFF;font-size:13px;height:30px;">密&nbsp;码:</div></td>
                      <td align="left">
                        <input type="password" name="user_pass" size="20" maxlength="16" style="border-color:#666666;"><p>
                      </td>
                    </tr>
                     
                    <tr>
    <td colspan="2">
                        <div align="center">
                          <input type="image" name="login" value=""  src="img/hotel_dl.jpg">
                      </div></td>
                    </tr>
                </table></td>
              </tr>
            </table>
      </form>
      </td>
    </tr>
    <tr><td>index_bc.php页面
    <?php
    session_start();
    if(!isset($_SESSION['FORMINDEX'])){
      header("location: index.php");
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>hotel后台管理</title>
    </head><frameset rows="120,*" cols="*" frameborder="NO" border="0" framespacing="0">
      <frame src="top.htm" name="topFrame" scrolling="NO" noresize />
      <frameset rows="*" cols="190,*" framespacing="0" frameborder="NO" border="0">
        <frame src="index_left.htm" name="leftFrame" scrolling="NO" noresize/>
        <frame src="index_content.htm" name="mainFrame" />
      </frameset>
    </frameset>
    <noframes><body>
    </body></noframes>
    </html>
      

  3.   

    我在地址栏中输入http://127.0.0.1/hotel_index/index_bc.php
    还是进入了index_bc页面,并没有跳转
      

  4.   

    不会的,你清空浏览器缓存再试,我这里是可以的。
    或者你在访问index_bc.php之前,已经打开过index.php了