0

I have a problem with adding php into html which includes frame. Here is my code;

    <?php
    session_start();
if (($_SESSION['accesslevel'] != "normal") ||($_SESSION['accesslevel'] != "admin" )) {
?>
    <meta http-equiv="refresh" content="0; url=./login.html">
    <?php}else {?>

<!DOCTYPE HTML>
<html lang="en">
<head>
<title>METU 3D Panaromic View</title>
<meta name="description" content="File Upload widget with multiple file selection, drag&amp;drop support, progress bar and preview images for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads.">
<meta name="viewport" content="width=device-width">
<!-- Bootstrap CSS Toolkit styles -->
<link rel="stylesheet" href="http://blueimp.github.com/cdn/css/bootstrap.min.css">
<!-- Generic page styles -->
<link rel="stylesheet" href="upload/css/style.css">
<!-- Bootstrap styles for responsive website layout, supporting different screen sizes -->
<link rel="stylesheet" href="http://blueimp.github.com/cdn/css/bootstrap-responsive.min.css">
<!-- Bootstrap CSS fixes for IE6 -->
<!--[if lt IE 7]><link rel="stylesheet" href="http://blueimp.github.com/cdn/css/bootstrap-ie6.min.css"><![endif]-->
<!-- Bootstrap Image Gallery styles -->
<link rel="stylesheet" href="http://blueimp.github.com/Bootstrap-Image-Gallery/css/bootstrap-image-gallery.min.css">
<!-- CSS to style the file input field as button and adjust the Bootstrap progress bars -->
<link rel="stylesheet" href="upload/css/jquery.fileupload-ui.css">
<!-- Shim to make HTML5 elements usable in older Internet Explorer versions -->
<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
    <frameset rows="40px,94%" BORDER=2 >
        <frame src="./normal_menu.html" noresize="noresize" scrolling="no" name="menu"/>
        <frameset cols="25%,75%" BORDER=2>
           <frame src="./map3.php?type=1" name="MAP" />
           <frame src="./view.html?fileName=findik.den.jpg" name="VIEW"/>
        </frameset>
    </frameset>
</head>
<body>
</body>
</html>
<?php}?>

It does not see if in php, hence it always redirects to login.html. How can i handle it without giving up frame.

Thanks.

4

4 回答 4

1

Your conditional here doesn't make sense:

if (($_SESSION['accesslevel'] != "normal") ||($_SESSION['accesslevel'] != "admin" )) {

One of these two conditions will always be true -- $_SESSION['accesslevel'] will always be either not-equal to "normal", or not-equal to "admin". (It can't be equal to both.)

You probably mean something like:

if (!($_SESSION['accesslevel'] == "normal" || $_SESSION['accesslevel'] != "admin")) {
于 2012-05-04T22:51:22.283 回答
1

真的应该使用 PHPheader函数而不是 HTML<meta>标记:

header('Location:login.html');

您当前执行此操作的方式是冒着将内容发送给他们不应访问的客户端的风险,然后重定向。

除此之外,我认为您的实际问题是布尔逻辑,看来您应该使用布尔 AND,而不是 OR:

if (($_SESSION['accesslevel'] != "normal") && ($_SESSION['accesslevel'] != "admin" )) {
于 2012-05-04T22:48:46.050 回答
0

我试过你的代码。数组 $_SESSION 为空!根据 php 手册(session_start 部分),“读取回调将检索任何现有的会话数据(以特殊的序列化格式存储)并将被反序列化并用于在读取回调返回保存的会话数据时自动填充 $_SESSION 超全局到 PHP 会话处理。” 因此,如果您之前没有进行任何会话,则似乎永远不会填充数组 $_SESSION 并且您对其进行的任何测试都不会给出任何有用的结果。

于 2012-05-04T23:19:57.867 回答
-1
<?php
session_start();
if (isset($_SESSION['accesslevel']) && !(($_SESSION['accesslevel'] == "normal") || ($_SESSION['accesslevel'] == "admin" ))) {
?>
于 2012-05-04T22:54:14.463 回答