Php 当我点击其他页面的按钮时,它会显示没有css的登录页面
因此,当我在项目顶部的localhost/mframe上打开代码时,它看起来是这样的 从这里,如果我点击主页按钮,它将显示与url完全相同的页面http://localhost/mframe/pages/index 并显示登录页的标题和导航,但它不使用css,如下所示 然后,如果我单击拍卖按钮,它将转到urlhttp://localhost/mframe/pages/auction 它显示的页面与上面没有css的登录页面相同,但它应该只显示导航,因为它是根据需要调用的 最后是关于我的页面,如果我点击它会打开一个空白的白色页面,而它应该使用css打开导航右上角的页面,但它就是这样空白的 我的代码是用mvc php设置的我的代码如下 config.php类Php 当我点击其他页面的按钮时,它会显示没有css的登录页面,php,model-view-controller,nav,Php,Model View Controller,Nav,因此,当我在项目顶部的localhost/mframe上打开代码时,它看起来是这样的 从这里,如果我点击主页按钮,它将显示与url完全相同的页面http://localhost/mframe/pages/index 并显示登录页的标题和导航,但它不使用css,如下所示 然后,如果我单击拍卖按钮,它将转到urlhttp://localhost/mframe/pages/auction 它显示的页面与上面没有css的登录页面相同,但它应该只显示导航,因为它是根据需要调用的 最后是关于我的页面,如
<?php
//Database params
define('DB_HOST', 'localhost'); //Add your db host
define('DB_USER', 'root'); // Add your DB root
define('DB_PASS', ''); //Add your DB pass
define('DB_NAME', 'auctionsystem'); //Add your DB Name
//APPROOT
define('APPROOT', dirname(dirname(__FILE__)));
//URLROOT (Dynamic links)
define('URLROOT', 'http://localhost/mframe');
//site name
define('SITENAME', 'Auction System');
myhead.php
<html lang="en">
<head>
<meta charset="UTF-8">
<meta htttp-equiv="Cache-control" content="no-cache">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo SITENAME; ?></title>
<link rel="stylesheet" href="css/style.css"/>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&display=swap" rel="stylesheet">
</head>
<body>
</body>
</html>
my navigation.php
<nav class="top-nav">
<ul>
<li>
<a href="<?php echo URLROOT; ?>/pages/index">Home</a>
</li>
<li>
<a href="<?php echo URLROOT; ?>/pages/about">About</a>
</li>
<li>
<a href="<?php echo URLROOT; ?>/pages/auction">Auction Items</a>
</li>
<li class="btn-login">
<a href="<?php echo URLROOT; ?>/users/login">Login/Signup</a>
</li>
</ul>
</nav>
拍卖/关于页面代码相同但打开时不同
<?php
require APPROOT . '/views/includes/head.php';
?>
<div class="navbar">
<?php
require APPROOT . '/views/includes/navigation.php';
?>
</div>
和index.php代码
<?php
require APPROOT . '/views/includes/head.php';
?>
<div id="section-landing">
<?php
require APPROOT . '/views/includes/navigation.php';
?>
<div class="wrapper-landing">
<div>
<h1>One Man crappy software</h1>
<h2>is another mans job</h2>
</div>
</div>
</div>
login.php代码
<?php
require APPROOT . '/views/includes/head.php';
?>
<div class="navbar">
<?php
require APPROOT . '/views/includes/navigation.php';
?>
</div>
<div class="container-login">
<div class="wrapper-login">
<h2>Sign in</h2>
<form action="<?php echo URLROOT; ?>/users/login" method="POST">
<input type="text" placeholder="Username *" name="username">
<span class="invalidFeedback">
<?php echo $data['usernameError']; ?>
</span>
<input type="password" placeholder="Password *" name="password">
<span class="invalidFeedback">
<?php echo $data['passwordError']; ?>
</span>
<button id="submit" type="submit" value="submit">
Submit
</button>
<p class="options">Not registered yet? <a href="<?php echo URLROOT;?>/users/register">Create an account!</a> </p>
</form>
</div>
</div>
因此,我需要知道为什么我在任何其他页面上都没有css为什么“关于”和“拍卖”页面的加载方式不同,尽管有相同的代码,还有为什么当我单击“主页”按钮时,它不会显示相同的登录页面,有两种类型的HTML重定向链接 绝对的和相对的 绝对值是:
<a href="https://www.example.com/page1.html">Link</a>
相对链接为:
<a href="page.html">Link</a>
您正在使用不带https://前缀的绝对链接。因此,它期望一个相对链接和添加绝对链接到您的域链接。
您可以添加http://或https://前缀来修复它。您的HREF是什么样子的?很有可能你链接到login而不是/login,那是我的navigation.php类。我相信我的url和点击的问题一定与我设置mvc的方式有关,因为它只是重复localhost full每个的路径click@tester在问题中编辑代码。注释中无法阅读。添加了代码我已修复了按钮链接,但是如果你阅读了我对答案的响应,它仍然不起作用,因为它不应该这样做到我的url根,按钮起作用,但当我单击“主页”按钮时,它加载不带css的登录页,不像我搜索url时,它加载带css的登录页有这个url,当我点击它带我去的主页时,没有css,但标题相同。当我点击拍卖网站时,它带我去,但它显示主页的标题,尽管auction.php文件没有任何内容,但需要标题和导航,所以它应该是一个带有导航栏的空白页面。不要将“页面/索引”添加到主页按钮。拍卖链接是正确的。这是另一个问题。您可以为此提出另一个问题并与之共享代码。