Well I decided to switch from Sessions, to cookies (Sessions were giving me too much trouble but thats another story) - but I ran into a problem with my cookie... They have to be sent before headers, but in this case - I don't think I can... Can someone help me? Is there a way to just call a cookie that was sent before the headers?
<?
include("../header.php");
include("config.php");
$a = new database();
$a->connect();
?>
<table width="100%" border=0 height="40">
<tr>
<td align="center"><font size="24"><b>Control Panel</b></font></td>
</tr>
</table>
<table width="100%" border="1" height="400">
<tr>
<td width="20%">
<?
$userinfo = $_COOKIE['cpanels'];
list($username, $password) = split('[,]', $userinfo);
$loginn = mysql_query("SELECT * FROM clients WHERE un='$username' AND pw='$password'");
if ($_COOKIE['cpanels']) {
if ($row = mysql_fetch_array($loginn, MYSQL_ASSOC)) {
print "blah blah";
}
}
else if ($HTTP_POST_VARS['action']) {
$pword = md5($_POST['password']);
$quser = mysql_query("SELECT * FROM clients WHERE un='".$_POST['username']."' AND pw='$pword'");
if ($row = mysql_fetch_array($quser, MYSQL_ASSOC)) {
print "User ".$row['user']." has successfully logged in<br>";
$value = "".$_POST['username'].", $pword";
setcookie("cpanels", $value,time()+3600,"/controls","domain.com");
}
else {
print "Invalid username or password<br>";
}
?>
<form action="<?php echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="0">
<input type="submit" value="Go back">
</form>
<?
} else {
?>
<b>Login:</b>
<form action="<?php echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="1">
Username:<br>
<input type="text" name="username" maxlength="24"><BR>
Password:<br>
<input type="password" name="password" maxlength="16"><br>
<center><INPUT TYPE="submit" value="Login"></center>
</form>
<? } ?>
</td>
<td>
</td>
</tr>
</table>
<?
include("../footer.php");
?>