在获取页面名称更新时遇到问题

时间:2019-02-13 04:42:05

标签: php

好,所以我一直在为网站编码一个市场脚本,试图使这些链接正常工作,由于某些原因,当用户单击链接时,页面名称不会更新为他们所使用的新页面正在查看页面更新的其余部分,而不是页面名称。所以我的链接显示如下所示:dashboard.php?account = withdraws。在网站上,仪表板页面名称仍显示为永不更新。因此,我将仪表板的PHP代码包括在内,希望有人可以帮助我解决此问题。

这是仪表板的顶部

<?php
// Seddeo Page System - Customer Dashboard
DEFINE("IN_SEDDEO", 1);

$pageName = "Dashboard";
$body = "customer-dashboard";

require_once('inc/config.php');
require_once('inc/header.php');

$account = $_GET['account'];
$action = isset($_GET['action']) ? $_GET['action'] : '';

// If no login go to login page
if(!$user->is_logged_in()){ 
    header('Location: signin.php?action=nologin'); 
}
if(isset($account)) {
     require_once("{$account}.php");
} else {
?>

这是仪表板的底部

<?php require_once('inc/footer.php'); ?>
<?php } ?>

我还包括了退出页面的PHP代码。

这是提款页面的顶部

<?php
// Seddeo Page System - Customer Dashboard
DEFINE("IN_SEDDEO", 1);

$pageName = "Account Settings";
$body = "dashboard-settings";

require_once('inc/config.php');
require_once('inc/header.php');

$account = $_GET['account'];
$action = isset($_GET['action']) ? $_GET['action'] : '';

// If no login go to login page
if(!$user->is_logged_in()){ 
    header('Location: signin.php?action=nologin'); 
}
?>   

页面底部

<?php require_once('inc/footer.php'); ?>

所以我希望有人能帮助我解决这个问题,谢谢。

好的,这是我的头文件

<?php
// Create a session only if we don't have one 
if (session_status() !== PHP_SESSION_ACTIVE) 
{ session_start(); 
}

// User data
$myID      = ($_SESSION["userID"])      ?: null; 
$ownerIP      = ($_SERVER["REMOTE_ADDR"])      ?: null; 
$myUser      = ($_SESSION["username"])      ?: null; 

if(!empty($myUser)) {
    $db->update('UPDATE members SET lastActive = NOW() WHERE username = ?', array($myUser)); 
    $info = $db->fetch("SELECT * FROM members WHERE username = ?", array($myUser));
    $rank = $info['rank'];
    $regIP = $info['ownerIP'];
    $lastLoginIP = $info['lastLoginIP'];
    $id = $info['memberID'];
    $my_Avatar = $info['my_Avatar'];
    $myMembership = $info['myMembership'];
    $account_type = $info['account_type'];
}

// Verified Page 
if(!DEFINED("IN_SEDDEO")) 
{ 
die("You cannot access this file directly."); 
}

if($account_type == 1) {
$isAccount = true;
} else {
$isAccount = false;
}
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">

    <!-- viewport meta -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="MartPlace - Complete Online Multipurpose Marketplace HTML Template">
    <meta name="keywords" content="app, app landing, product landing, digital, material, html5">


    <title>Seddeo - <?php echo $pageName; ?></title>

    <!-- inject:css -->
    <link rel="stylesheet" href="css/animate.css">
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/fontello.css">
    <link rel="stylesheet" href="css/jquery-ui.css">
    <link rel="stylesheet" href="css/lnr-icon.css">
    <link rel="stylesheet" href="css/owl.carousel.css">
    <link rel="stylesheet" href="css/slick.css">
    <link rel="stylesheet" href="css/trumbowyg.min.css">
    <link rel="stylesheet" href="css/bootstrap/bootstrap.min.css">
    <link rel="stylesheet" href="style.css">
    <!-- endinject -->

    <!-- Favicon -->
    <link rel="icon" type="image/png" sizes="16x16" href="images/favicon.png">
</head>

1 个答案:

答案 0 :(得分:0)

据我所知,在inc/header.php文件之前包含了account.php文件。

您将看到$pageName文件中使用了inc/header.php变量。

但是$pageName的值仅被更改,其中包含inc/header.php文件...这意味着该值将总是为它是初始值,即:Dashboard

总结:

dashboard.php
  \-> $pageName = 'Dashboard'
  \-> loads header.php
  \-> $pageName is still 'Dashboard'
  \-> <title> tag uses $pageName
  \-> load account.php
  \-> $pageName = "Account Settings" (which doesn't matter since it has already been used in header.php

为解决您的问题,我建议将以下内容添加到dashboard.php

之前行:

require_once('inc/config.php');
require_once('inc/header.php');
$titles = [
 'dashboard.php' => 'Dashboard',
 'dashboard.php?account=update-account' => 'Account Settings'
];
$pageName = isset( $titles[ $_SERVER['REQUEST_URI'] ] ) ? $titles[$_SERVER['REQUEST_URI'] ] : 'Dashboard'