Weird "?>" being displayed

Posted by Jaxkr on Stack Overflow See other posts from Stack Overflow or by Jaxkr
Published on 2012-07-08T02:28:21Z Indexed on 2012/07/08 3:15 UTC
Read the original article Hit count: 116

Filed under:

I have the following navigation bar script:

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

For some reason, a strange "?>" is being displayed. I am super confused, so please help.

Here is includepath.inc.php (the only I reason it's there is because I am on a shared host, and I don't want to type '/home/bigdumbhash/public_html/include' everytime. But, here it is:

 <?php
 $include_path = '/home/a6595899/public_html/include/';
 ?>

Here is loginsysfunc.inc.php. These are functions that go with my login system to save time:

<?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\'">';
}

?>

Here is the actual HTML of the page:

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

© Stack Overflow or respective owner

Related posts about php