hello
i use the fallowing code for my login page but it gives me the fallowing error i was wondering what is the problem? (line 179 is the setcookie)
by the way it doesn't set the cookie
any help would be appreciated
error:
my code:
<?
include_once('functions.php');
function cleanQuery($string)
{
if(get_magic_quotes_gpc()) // prevents duplicate backslashes
{
$string = stripslashes($string);
}
$badWords = "(delete)|(update)|(union)|(insert)|(drop)|(http)|(--)";
$string = eregi_replace($badWords, "", $string);
if (phpversion() >= '4.3.0')
{
$string = mysql_real_escape_string($string);
}
else
{
$string = mysql_escape_string($string);
}
return $string;
}
if (isset($_COOKIE['scmuser'])) {
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=index.php\">";
}else{
if ($_POST['username']) {
//did they supply a password and username
$username=cleanQuery($_POST['username']);
$password=cleanQuery($_POST['password']);
if ($password==NULL || $username==NULL) {
?>
<p align="center">
<font color="#FF0000">Username or password wasn't supplied!</font><form action="login_acc.php" method="POST">
<table style="border:1px solid #FFFFFF;" width="90%" align="center">
<tr>
<td align="center">Username: </td>
<td align="center">
<input type="text" size="20" maxlength="25" name="username" /></td>
</tr>
<tr>
<td align="center">Password: </td>
<td align="center">
<input type="password" size="20" maxlength="25" name="password" /></td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Login"/> </td>
</tr>
<tr>
<td align="center" colspan="2">
<a href="register.php">Register</a> - <a href="forgetpass.php">Forgot Your Password?</a>
</td>
</tr>
</table>
</form>
<?
}else{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['password'] != $password) {
?>
<p align="center">
<font color="#FF0000">The supplied login was incorrect</font><form action="login_acc.php" method="POST">
<table style="border:1px solid #FFFFFF;" width="90%" align="center">
<tr>
<td align="center">Username: </td>
<td align="center">
<input type="text" size="20" maxlength="25" name="username" /></td>
</tr>
<tr>
<td align="center">Password: </td>
<td align="center">
<input type="password" size="20" maxlength="25" name="password" /></td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Login"/> </td>
</tr>
<tr>
<td align="center" colspan="2">
<a href="register.php">Register</a> - <a href="forgetpass.php">Forgot Your Password?</a>
</td>
</tr>
</table>
</form>
<?
}else{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
setcookie("scmuser", "$username", time()+3600);
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=index.php\">";
}
}
}
}
?>
thank you