my login system is awesome, i added one small thing and BAM it broke, i cant see the problem but i hope to have it fixed here, here is my code for my login page
<?PHP
include_once("sql.php");
if (isset($_POST["user"])) {
if (isset($_POST["pass"])) {
if ($_POST["user"] == "") {
login("u");
}
else {
$loggedIn = false;
$result = mysql_query("select * from users;");
while($row = mysql_fetch_assoc($result)) {
if ($_POST["user"] == $row["user"]) {
if ($_POST["pass"] == $row["password"]) {
$loggedIn = true;
setCookie("user",$row["user"], time()+3600);
setCookie("password",$row["password"],time()+3600);
setCookie("team",$row["team"], time()+3600); \\ added this (a new colium in the table)
break;
}
}
}
if ($loggedIn) {
print "
<a href=\"index.php\">Login</a>
";
}
else {
login("up");
}
}
}
else {
if ($_POST["user"] == "") {
login("up");
}
else {
login("p");
}
}
}
else {
login("");
}
function login($error) {
$user = "";
$pass = "";
if ($error == "u") {
$user = "<br />Username is incorrect";
}
if ($error == "p") {
$pass = "<br />Password is incorrect";
}
if ($error == "up") {
$user = "<br />Username not used";
$pass = "<br />Password is incorrect";
}
// form here just simple "username" and "password" fields
}
?>
note: my website is only small
thanks