Hi, my code wont work. It either cannot redeclare tabeltop(); or it dont do the sessions:
Warning: Cannot send session cache limiter - headers already sent (output started at c:\program files\apache group\apache\htdocs\dark realms online\ofp\members\scripts\functions.php:47) in c:\program files\apache group\apache\htdocs\dark realms online\ofp\members\accesscontrol.php on line 2
Here is the code:
Accesscontrol.php:
<?
session_start();
include ("db.php");
dbConnect("ofp");
$rresult = mysql_query("SELECT * FROM members WHERE username = '$uid' AND password = '$pwd'");
while ($row = mysql_fetch_array($rresult)) {
$rank = $row["rank"];
}
if(!isset($uid)) {
include("login.php");
}
session_register("uid");
session_register("pwd");
session_register("rank");
$sql = "SELECT * FROM members WHERE username = '$uid' AND password = '$pwd'";
$result = mysql_query($sql);
if (!$result) {
session_destroy();
error("A database error occurred while checking your login details.\nIf this error persists, please contact dragon3l33t@aol.com.");
}
if (mysql_num_rows($result) == 0) {
session_destroy();
memheader("Access denied");
tabletop("Access Denied","100%");
?>
<p align=left>Access denied, click <a href="news.php">here</a>.
<?
tablebot("100%");
exit;
}
news.php (the page im using to check if the member is on it or not):
<?
include("scripts/functions.php");
include("accesscontrol.php");
if ($action == "logout") {
session_destroy();
include("login.php");
}
else {
memheader("News");
tabletop("Member Area","85%");
?>
<p align=left>
Welcome, <?=$username?>! You have entered a members-only area of the site.
Don't you feel special? <br>
<a href="news.php?action=logout">Logout</a><br><br>
<?
tablebot("85%");
?>
</body>
<?}?>
scripts/functions.php:
<?
function tabletop($title,$percent) {
?>
<TABLE cellSpacing=0 cellPadding=0 bgColor=#000000 border=0 width=<?=$percent?>>
<TBODY>
<TR>
<TD width=30 height=43><IMG height=43 src="images/mainleft.gif" width=30></TD>
<TD width=174 background="images/maintitleback.gif" height=43><IMG height=1 src="images/spacer.gif" width=174><BR><B><?=$title?></B></TD>
<TD width=30 height=43><IMG height=43 src="images/mainmiddle.gif" width=30></TD>
<TD width="100%" background="images/mainrightback.gif" height=43><IMG height=1 src="images/spacer.gif" width=100></TD>
<TD width=48 height=43><IMG height=43 src="images/mainright.gif" width=30></TD>
</TR>
</TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 bgColor=#000000 border=0 width=<?=$percent?>>
<TBODY>
<TR>
<TD vAlign=bottom width=15 background="images/mainsideleft.gif"><IMG src="images/mainsideleftbot.gif" width=16></TD>
<TD vAlign=top width="100%" bgColor=#2a2a2a><center>
<?
}
function tablebot($percent) {
?>
</TD>
<TD vAlign=top width=16 background="images/mainsideright.gif"><IMG src="images/mainsiderighttop.gif" width=16></TD>
</TR>
</TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 bgColor=#000000 border=0 width=<?=$percent?>>
<TBODY>
<TR>
<TD width=30 height=26><IMG height=26 src="images/mainbotleft.gif" width=30></TD>
<TD width=172 background="images/mainbotback.gif" height=26><IMG height=1 src="images/spacer.gif" width=172></TD>
<TD width=26 height=26><IMG height=26 src="images/mainbotmiddle.gif" width=26></TD>
<TD width="100%" background="images/mainbotback2.gif" height=26><IMG height=1 src="images/spacer.gif" width=100></TD>
<TD width=26 height=26><IMG height=26 src="images/mainbotright.gif" width=26></TD></TR></TBODY></TABLE></TD>
<TD width="100%"> </TD>
</TR>
</TBODY>
</TABLE>
<?
}
?>
<?
function error($msg) {
?>
<head>
<script language="JavaScript">
<!--
alert("<?=$msg?>");
history.back();
//-->
</script>
</head>
<body>
</body>
<?
exit;
}
function memheader($page) {
?>
<HEAD>
<TITLE>.::[ Dark Realms Online ]::. .::[ Operation Flashpoint ]::. .::[ <?=$page?> ]::.</TITLE>
<link rel="stylesheet" type="text/css" href="scripts/mem.css">
</HEAD>
<BODY bgcolor=black>
<?}?>
login.php (the page it includes if there isnt a session there):
<?
memheader("Log In");
tabletop("Log In","60%");
?>
<p align=left><form method="post" action="<?=$PHP_SELF?>">
<font style='font-size:7pt'>Username<br><input type="text" name="uid" size="20" class="text"><br>
<font style='font-size:7pt'>Password<br><input type="password" name="pwd" SIZE="20" class="text"><br><br>
<input type="submit" value="Log in" class="smbutton"> </form></p>
<?
tablebot("60%");
exit;
?>