我有以下导航栏脚本:
<?php session_start();
require('includepath.inc.php');
require($include_path.'loginsysfunc.inc.php');
$current_page = $_SERVER['REQUEST_URI'];
?>
<div class="navbar">
<img class="navlogo" src="logo.png">
<div class="navbutton"><a href="index.php">Home</a></div>
<div class="navbutton"><a href="about.php">About</a></div>
<div class="navbutton"><a href="donate.php">Donate</a></div>
<?php
if (loggedIn()){
?>
<div class="navusername"><a href="profile.php?user=<?php echo $_SESSION['username'];?>"><?php echo $_SESSION['username']; ?></a></div>
<div class="navtoolsettings"><a href="settings.php">Settings</a></div>
<div class="navtoollogout"><a href="logout.php">Log out</a>
<?php
} elseif ($current_page == '/login.php') {
?>
<div class="navregister"><a href="register.php">Register</a></div>
<?php
} else {
?>
<div class="navusername"><a href="login.php">Log in</a></div>
<?php
}
?>
</div>
出于某种原因,一个奇怪的“?&gt;” is being displayed。我非常困惑,所以请帮忙。
这是includepath.inc.php(唯一的原因是因为我在共享主机上,而且我不想每次都输入'/ home / bigdumbhash / public_html / include'。但是,这里它是:
<?php
$include_path = '/home/a6595899/public_html/include/';
?>
这是loginsysfunc.inc.php。这些功能与我的登录系统一起使用以节省时间:
<?php
function valUser() {
session_regenerate_id();
$_SESSION['valid'] = true;
$_SESSION['username'] = $userid;
echo '<meta http-equiv="refresh" content="0;URL=\'index.php\'">';
}
function loggedIn()
{
if($_SESSION['valid'] == true) {
return true;
} else {
return false;
}
}
function createSalt() {
$string = $string = md5(uniqid(rand(), true));
return substr($string, 0, 3);
}
function logout()
{
$_SESSION = array();
session_destroy();
echo '<meta http-equiv="refresh" content="0;URL=\'index.php\'">';
}
?>
以下是该页面的实际HTML:
<!DOCTYPE html>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<title>
Log in
</title>
</head>
<body>
<div class="navbar">
<img class="navlogo" src="logo.png">
<div class="navbutton"><a href="index.php">Home</a></div>
<div class="navbutton"><a href="about.php">About</a></div>
<div class="navbutton"><a href="donate.php">Donate</a></div>
<div class="navregister"><a href="register.php">Register</a></div>
</div> ?>
<div class="loginbox">
<h1>Log in</h1>
<form action="logingo.php" method="POST">
<input class="userpass" type="text" name="username" value="Username" onFocus="this.value='';">
<br>
<input class="userpass" type="password" name="password" value="Password" onFocus="this.value='';">
<br>
<input class="loginbutton" type="submit" value="Log in!">
</form>
</div>
</body>
</html>
答案 0 :(得分:4)
<?php session_start();
require('includepath.inc.php');
require($include_path.'loginsysfunc.inc.php');
$current_page = $_SERVER['REQUEST_URI'];
?>
<div class="navbar">
<img class="navlogo" src="logo.png">
<div class="navbutton"><a href="index.php">Home</a></div>
<div class="navbutton"><a href="about.php">About</a></div>
<div class="navbutton"><a href="donate.php">Donate</a></div>
<?php
if(loggedIn()){
?>
<div class="navusername"><a href="profile.php?user=<?php echo $_SESSION['username'];?>"><?php echo $_SESSION['username']; ?></a></div>
<div class="navtoolsettings"><a href="settings.php">Settings</a></div>
<div class="navtoollogout"><a href="logout.php">Log out</a>
<?
}else if($current_page == '/login.php'){
?>
<div class="navregister"><a href="register.php">Register</a></div>
<?
}else{
?>
<div class="navusername"><a href="login.php">Log in</a></div>
<?php
}
?>
</div>
答案 1 :(得分:1)
根据您发布的HTML输出,问题似乎出现在显示<div class="loginbox">
的文件中(之前)。
看看该文件的内容。