此表格是我的主页。登录后,我无法进入主页 因为这个错误。
解析错误:语法错误,文件意外终止于
C:\ xampp \ htdocs \ kusina_online \ home.php,第28行
<?php
include('session.php');
if(!isset($_SESSION['login_user'])) {
header("location: index.php");
?>
<DOCTYPE! html>
<html lang="en">
<head>
<title>Kusina Online</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial- scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="bootstrap/js/jquery-slim.min.js"></script>
<script type="text/javascript" src="bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>
</head>
<body>
<br /><br />
<div class="container" style="width:500px;">
<h3 align="center">Kusina Online</h3>
<br />
<b id="welcome">Howdy, <i><?php echo $login_session; ?></i></b>
<div class="desc"><b id="logout"><a href="logout.php">Log Out</a></b></div>
</div>
</body>
</html>
答案 0 :(得分:2)
PHP返回此错误,因为您没有正确结束if语句。如果这样做,您的代码将如下所示:
if(!isset($_SESSION['login_user'])) {
header("location: index.php");
}
或者,如果您只需要运行一行代码,则可以像下面这样格式化
if(!isset($_SESSION['login_user']))
header("location: index.php");
答案 1 :(得分:2)
您可以在这里参考。
<?php
include('session.php');
if(!isset($_SESSION['login_user'])) {
header("location: index.php");
} // you not closing this statement.
?>
<DOCTYPE! html>
<html lang="en">
<head>
<title>Kusina Online</title>
<meta charset="utf-8"> <!--- maybe a typo why would `/` be here.--->
<meta name="viewport" content="width=device-width, initial- scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="bootstrap/js/jquery-slim.min.js"></script>
<script type="text/javascript" src="bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>
</head>
<body>
<br /><br />
<div class="container" style="width:500px;">
<h3 align="center">Kusina Online</h3>
<br />
<b id="welcome">Howdy, <i><?php echo $login_session; ?></i></b>
<div class="desc"><b id="logout"><a href="logout.php">Log Out</a></b></div>
</div>
</body>
确保检查每一行
答案 2 :(得分:0)
您应该在第6行放置一个右括号。
<?php
include('session.php');
if(!isset($_SESSION['login_user'])) {
header("location: index.php");
}
?>
答案 3 :(得分:0)
您忘记合上第6行中的括号...
<?php
include('session.php');
if(!isset($_SESSION['login_user'])) {
header("location: index.php");
?>
<DOCTYPE! html>
<html lang="en">
<head>
<title>Kusina Online</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial- scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="bootstrap/js/jquery-slim.min.js"></script>
<script type="text/javascript" src="bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>
</head>
<body>
<br /><br />
<div class="container" style="width:500px;">
<h3 align="center">Kusina Online</h3>
<br />
<b id="welcome">Howdy, <i><?php echo $login_session; ?></i></b>
<div class="desc"><b id="logout"><a href="logout.php">Log Out</a></b></div>
</div>
</body>
</html>