admin管理员组文章数量:1122832
I'm setting up the primary files for a user management system. I'm following the steps for a tutorial I found on YouTube.
I've come across a problem. In index.php
I've set up things so that you get sent to a login screen if the GET variable isn't set or is empty. If it's not empty or unset, then there are other conditions to either show a specific view, default to the login page, or return a 404 error.
The problem is that when I enter the URL index.php?view=home
, I should see:
- The navbar
- The contents of home.php
- There's also a JS script for toggling the navbar (I'm using Bulma CSS).
Instead, what I get is a 404 error. Inputting index.php?view=login
indeed takes me to the login screen, so I'm not sure what's wrong with home specifically.
Here's the contents of index.php (you can also see the repo here:
<?php require "./inc/session_start.php"; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php
# HTML header
include "./inc/head.php";
?>
</head>
<body>
<?php
if ( !isset( $_GET["view"] ) || $_GET["view"] == "" ) {
$_GET["view"] = "login";
}
# Display views that exist and aren't "login" nor "404"
if ( is_file("./view" . $_GET["view"] . ".php") && $_GET["view"] != "login" && $_GET["view"] != "404" ) {
include "./inc/navbar.php";
# Load current view
include "./views" . $_GET["view"] . ".php";
include "./inc/navbar_toggle_script.php";
} else {
if ( $_GET["view"] == "login" ) {
include "./views/login.php";
} else {
include "./views/404.php";
}
}
?>
</body>
</html>
I tried verifying if there was a typo in the index.php
file or some problem with the logic but I can't seem to see any issues.
本文标签:
版权声明:本文标题:The URL `http:localhostsimple_user_management_systemindex.php?view=home` should load content but returns 404 error - Stack Overf 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736306058a1932815.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论