That works fine... except something else doesn't:
<?
if ($_SESSION['username'])
{
?>
<?php include ("memberbar.php");?>
<?
}
else
{
?>
<?php include ("login.php");?>
<?
}
?>
It doesn't have session_start(); because if I put tht in the code it says:
Warning: Cannot send session cookie - headers already sent by (output started at /path/whatever.php) in /path/whatever.php on line 81
The login.php code is as follows:
<tr>
<td width="100%" bgcolor="#C0C0C0">
<form method="POST" action="index.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:</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>
And the memberbar.php code is:
<?php
$link = mysql_connect("localhost", "zingbats", "my 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 WHERE user_password = md5('$_SESSION[password]')";
$result = mysql_query($query) or die("Query failed");
$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!</td>
</tr>