0

我有以下导航栏脚本:

<?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>

出于某种原因,正在显示一个奇怪的“?>” 。我很困惑,所以请帮忙。

这是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>
4

2 回答 2

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>
于 2012-07-08T02:32:17.347 回答
1

根据您发布的 HTML 输出,问题似乎出在显示的文件中<div class="loginbox">(在此之前)。
查看该文件的内容。

于 2012-07-08T03:11:31.803 回答