for some reason, i was switching my system from sessions to cookies, and well, my login will not set the cookie, therefore the site thinks you are not logged in messing up alot of things.
if you can think of anything, please let me know.
code:
<?php
# ini_set('error_reporting', E_ALL);
?><head>
<style type="text/css">
<!--
.loginheader {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
font-style: normal;
line-height: 24px;
font-weight: normal;
font-variant: normal;
text-transform: none;
color: #FFFFFF;
background-image: url(cat.jpg);
background-repeat: no-repeat;
background-position: center top;
width: 650px;
}
</style>
</head>
<?php
$where = $_SERVER['HTTP_REFERER'];
include('inc/connect.php');
include('inc/class_core.php');
include('inc/config.php');
$login = $_COOKIE['username'];
/* ######## IF ALREADY LOGGED IN REDIRECT TO HOME ######## */
if($login)
{
echo "<script>window.location=\"index.php\"</script>";
}
if ($_POST['username']) {
$username=$_POST['username'];
$password=$core->encrypt($_POST['password']);
if ($password==NULL) {
echo "<font face='verdana' size='2'>No password given.";
}else{
$query = mysql_query("SELECT username,password FROM {$TABLE_PREFIX}_users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['password'] != $password) {
echo "Incorrect login, try again.";
}else{
$query = mysql_query("SELECT username,password FROM {$TABLE_PREFIX}_users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
$value = $row['username'];
/* ###### SET THE COOKIE TITLED TO THE USERNAME THEY LOGGED IN AS ###### */
setcookie("username", $value, -1);
/* ###### REDIRECT TO HOME PAGE ###### */
echo "<script>
window.location=\"index.php\"
</script>";
}
}
}
?>
<center>
<div class="loginheader">Login</div>
<table border="1" width="650">
<tr>
<td height="226">
<Center>
<font face="verdana" size="2">
If you do not have an account please <A href="register.php">Sign up</A> for free, if you have an account but have
lost your password then click <a href="#">here</a>.
<br />
<br />
<form action="login.php" method="POST">
Username:
<input type="text" name="username" value="Username" onFocus="this.value=''" />
<br />
Password:
<input type="password" name="password" value="Password" onFocus="this.value=''" />
<br />
<input type="submit" name="submit" value="Login" />
</form>
<Br />
</td>
</tr>
</table>
<?php
include('footer.php');
echo "<br><br><br>";
include('poweredby.php');
?>
</center>