I am having problems with this login script. It works, only after you successfully login, I use a header() to relocate you to the main page. But the header isn't working. I don't think I have any data I sent to the page. I'll mark it with **** the area I need help with. But here's the whole code:
<head></head>
<body bgcolor="#000000" text="#ffffff">
<?php
require ("univvars.php");
if (mysql_connect($Host, $User, $Pass))
{
//then run this
if (mysql_select_db($DBName, $Link))
{
$Tablename = "test";
$Query = "SELECT * from test WHERE Username='$Array[Username]' AND Password='$Array[Password]'";
$Result = mysql_query($Query, $Link);
$num = mysql_num_rows($Result);
//If the user has already Submitted his login info
*******************Here
if ($Submitted)
{
//If there is only 1 row that matches Username and password,
if ($num == "1")
{
$Logged = "yes";
header("Location: index.php");
exit;
}
else
{
//else there is more than 1 row, or less than 1 row. exit script and refuse login
print ("<td>Login unsuccessful, please enter valid username/password combination!</td>");
exit;
***************To here************
}
}
//if the user hasn't entered his login info
else
{
print ("<td><center><b>Login:</b><br>");
print ("<tabe border=1 width=\"25%\"><form action=\"login.php\" method=POST>");
print ("Username:<br>");
print ("<input type=text name=\"Array[Username]\">");
print ("<p>Password:<br>");
print ("<input type=password name=\"Array[Password]\"><br>");
print ("<input type=hidden name=\"Submitted\" value=\"TRUE\">");
print ("<br><input type=Submit name=\"Submit\" value=\"Submit\"></td>");
}
}
}
else
{
print ("Could not open page. Please try back later. If problem persists, contact webmaster at soldier_of_rome@hotmail.com.");
}
?>