簡體   English   中英

將PHP添加到HTML框架

[英]adding php to html frame

我在將PHP添加到包含框架的html中時遇到問題。 這是我的代碼;

    <?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。 我如何在不放棄框架的情況下進行處理。

謝謝。

確實應該使用PHP header函數代替HTML <meta>標簽:

header('Location:login.html');

您目前的做法是冒着向客戶端發送他們不應該訪問的內容的風險,然后才進行重定向。

除此之外, 我認為您的實際問題是布爾邏輯 ,似乎您應該使用布爾AND,而不是OR:

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

您的條件在這里沒有意義:

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

這兩個條件之一將始終為真- $_SESSION['accesslevel']將始終不等於“ normal”或不等於“ admin”。 (不能等於兩者。)

您可能的意思是:

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

我嘗試了您的代碼。 數組$ _SESSION為空! 根據php手冊(session_start部分),“讀回調將檢索任何現有的會話數據(以特殊的序列化格式存儲),並且將被反序列化並用於在讀回調將保存的會話數據返回時自動填充$ _SESSION超全局變量。 PHP會話處理。” 因此,如果您之前沒有進行任何會話,則似乎永遠不會填充$ _SESSION數組,並且您對其進行的任何測試都不會給出任何有用的結果。

<?php
session_start();
if (isset($_SESSION['accesslevel']) && !(($_SESSION['accesslevel'] == "normal") || ($_SESSION['accesslevel'] == "admin" ))) {
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM