首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将php添加到html框架

将php添加到html框架
EN

Stack Overflow用户
提问于 2012-05-05 06:39:09
回答 4查看 1.4K关注 0票数 0

我有一个问题,添加php到html,其中包括框架。这是我的代码;

代码语言:javascript
复制
    <?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}?>

它看不到是否在php中,因此它总是重定向到login.html。我怎么才能在不放弃frame的情况下处理它。

谢谢。

EN

回答 4

Stack Overflow用户

发布于 2012-05-05 06:48:46

你应该使用PHP的header函数而不是超文本标记语言的<meta>标签来:

代码语言:javascript
复制
header('Location:login.html');

以你目前的方式,你冒着向客户端发送他们不应该访问的内容的风险,然后重定向。

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

代码语言:javascript
复制
if (($_SESSION['accesslevel'] != "normal") && ($_SESSION['accesslevel'] != "admin" )) {
票数 1
EN

Stack Overflow用户

发布于 2012-05-05 06:51:22

这里的条件没有任何意义:

代码语言:javascript
复制
if (($_SESSION['accesslevel'] != "normal") ||($_SESSION['accesslevel'] != "admin" )) {

这两个条件中的一个将 always 设置为true -- $_SESSION['accesslevel']将始终不等于"normal",或者不等于"admin“。(它不能同时等于两者。)

你的意思可能是这样的:

代码语言:javascript
复制
if (!($_SESSION['accesslevel'] == "normal" || $_SESSION['accesslevel'] != "admin")) {
票数 1
EN

Stack Overflow用户

发布于 2012-05-05 07:19:58

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10457016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档