The code below is part of a login form, if the username is in a database called terminated_request then it will give Error1 when someone tries to sign in. If the username is in a database called terminated_request then it will give Error2. If the username is not in any of those two databases, then it will log the user in.
It all works but it gives me an error when the user can login.
The code is below, and so is the error message. Please assist if you can.
<?
include("config.php");
$connection = mysql_connect("$server", "$db_user", "$db_pass");
$db = mysql_select_db("$database", $connection);
$query = "SELECT * FROM terminated_accounts where username='$username'";
$result = mysql_query($query, $connection);
$exterminated=mysql_numrows($result);
?>
<?
include("config.php");
$connection = mysql_connect("$server", "$db_user", "$db_pass");
$db = mysql_select_db("$database", $connection);
$query = "SELECT * FROM terminated_request where username='$username'";
$result = mysql_query($query, $connection);
$exterminationrequest=mysql_numrows($result);
?>
<?
include("config.php");
if($loged=='yes')
{
echo "You are already logged in!";
echo "<a href=\"logout.php\" accesskey=\"l\">$lang[logout]</a>";
}
else
{
$connection = mysql_connect("$server", "$db_user", "$db_pass");
$db = mysql_select_db("$database", $connection);
$query = "SELECT * FROM login where username='$username'";
$result = mysql_query($query, $connection);
$rows = mysql_fetch_array($result);
$pass = $rows[password];
$email = $rows[email];
$name = $rows[fname];
}
if($password=='' OR $username=='')
{
echo "$lang[useloginform]";
}
elseif($exterminated=='1')
{
echo "$lang[paragraph_one_tos_violation]";
}
elseif($exterminationrequest=='1')
{
echo "$lang[member_request_termination]";
}
elseif($password==$pass)
{
setcookie("loged","yes",time()+3600);
setcookie("username","$username",time()+3600);
setcookie("name","$name",time()+3600);
setcookie("email","$email",time()+3600);
echo "$lang[thanksforlogin]";
include("welcomepage.php");
}
else
{
echo "$lang[wrongpass]";
}
?>
Error message:
Warning: Cannot modify header information - headers already sent by (output started at /home/paddy/public_html/login.php:10) in /home/paddy/public_html/login.php on line 54
Warning: Cannot modify header information - headers already sent by (output started at /home/paddy/public_html/login.php:10) in /home/paddy/public_html/login.php on line 55
Warning: Cannot modify header information - headers already sent by (output started at /home/paddy/public_html/login.php:10) in /home/paddy/public_html/login.php on line 56
Warning: Cannot modify header information - headers already sent by (output started at /home/paddy/public_html/login.php:10) in /home/paddy/public_html/login.php on line 57
LINE 54:
setcookie("name","$name",time()+3600);
LINE 55:
setcookie("email","$email",time()+3600);
LINE 56:
echo "$lang[thanksforlogin]";
LINE 57:
include("welcomepage.php");