I have a HTML page (index.php) that includes a file called header.php
header.php is made to show a login bar if a session called username exsistes. THe only trouble is.. I have to put the header.php code ON the index.php for it to work.
<?
session_start;
?>
is at the top of index.php. Here is the code for header and the top bit of index.php
header.php
<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="96%" id="AutoNumber3">
<tr>
<td width="100%" bgcolor="#C0C0C0">
<i><b>
<font color="#333333" size="4">Key Links</font></b></i><font color="#333333">:
</font> <b>
<font color="#333333"><a href="http://www.tycooneden.com/index2.php" style="text-decoration: none">Homepage</a></font></b><font color="#333333">
::
</font> <b><font color="#333333">
<a href="http://forums.tycooneden.com/" style="text-decoration: none">Forums</a></font></b><font color="#333333">
:: </font> <b>
<font color="#333333"><a style="text-decoration: none" href="http://downloads.tycooneden.com">Downloads</a></font></b><font color="#333333"> ::
</font>
<b><font color="#333333"><a href="http://uploads.tycooneden.com" style="text-decoration: none">Uploads</a></font></b><font color="#333333"> :: <b>
<a href="http://hosting.tycooneden.com/" style="text-decoration: none">
Hosting</a> </b>:: <b><a href="http://hosting.tycooneden.com/hosted" style="text-decoration: none">Network Sites </a></b></font>
:: <font color="#333333"><b>
<a style="text-decoration: none" href="http://www.tycooneden.com/clan">T.E.C.C</a></b></font></td>
</tr>
[color=blue]
<?
if ($_SESSION['username'])
{
?>
<?php
$link = mysql_connect("localhost", "username", "pwl")
or die("Could not connect");
mysql_select_db("tycooneden_com") or die("Could not select database");
$query = "SELECT * FROM phpbb_users WHERE username = '$_SESSION[username]' AND user_password = md5('$password')";
$result = mysql_query($query) or die("Query is messed up! So yure buggered");
$foo=mysql_fetch_array($result);
/* Start the clan defining */
$user_points=$foo['user_points'];
mysql_close($link);
?>
<tr>
<td width="100%" bgcolor="#C0C0C0">
Welcome <? echo ("$_SESSION[username]");?>, you have £<? echo ("$user_points");?>, get spending and earning!
- <a href="http://www.tycooneden.com/logout.php">Logout</a></td>
</tr>
<?
}
else
{
?>
<tr>
<td width="100%" bgcolor="#C0C0C0">
<form method="POST" action="http://www.tycooneden.com/login.php">
<div align="left">
<table border="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111" width="53%" id="AutoNumber5">
<tr>
<td width="17%"><b><i><font size="4" color="#333333">Login: <? echo ("$username");?><? echo ("$_SESSION[username]");?></font></i></b><font color="#333333"><b> </b></font><font size="4" color="#333333"> </font></td>
<td width="15%"><font color="#333333"><b> User:</b></font></td>
<td width="19%"><input type="text" name="username" size="20"></td>
<td width="17%"><font size="4" color="#333333"> Password:</font></td>
<td width="16%"><input type="password" name="password" size="20"></td>
<td width="16%"><input type="submit" value="Login" name="B1"></td>
</tr>
</form>
</table>
</div>
</td>
</tr>
</table>
</center>
</div>
<?
}
?>
</body>
[/color]
The index bit is:
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
?>
<html>
<head>
<title>TycoonEden.com - Live the reality. (Viewing in GREY) </title>
</head>
<body bgcolor="#333333">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="AutoNumber1" bordercolorlight="#999999" bordercolordark="#000000" bgcolor="#808080" bordercolor="#666666">
<tr>
<td width="12%"><br>[color=red]<? include "header.php";?>[/color]
<div align="center">
The script just doesn't show the top bar. Even if U are logged in, it shows the login bar 🙁