Here is my code:
<?php
include("db.php");
if (array_key_exists("loginname", $HTTP_COOKIE_VARS)){
$username = $HTTP_COOKIE_VARS['loginname'];
} else {
$username = "";
}
if($username != "") {
print ($username.", you are already logged in.<br>");
print("<form method=\"post\" action=\"\">");
print("<input type=\"Submit\" name=\"logout\" value=\"Log Out?\"></td></tr></table>");
print("</form>");
if(isset( $logout )) {
setcookie("loginname");
}
} else {
print("<form method=\"post\" action=\"\">");
print("<table><tr><td>Name</td>");
print("<td><input type=\"textfield\" name=\"name\"></td></tr>");
print("<tr><td>Password</td>");
print("<td><input type=\"textfield\" name=\"password\"></td></tr><tr><td colspan=\"2\">");
print("<input type=\"Submit\" name=\"Submit\" value=\"Log In\"></td></tr></table>");
print("</form>");
}
if(isset( $Submit )) {
$username = $HTTP_POST_VARS['name'];
$password = $HTTP_POST_VARS['password'];
$rs = mysql_query("SELECT * FROM users WHERE name = '$username' AND password = '$password' ");
if (mysql_num_rows($rs)>0) {
print ("successfully logged in");
setcookie("loginname",$username);
}
}
?>
When I log in it gives me this error:
Warning: Cannot modify header information - headers already sent by (output started at /home/halflife/public_html/emblem/login.php:12) in /home/halflife/public_html/emblem/login.php on line 26
And when I enter a page where it checks if I'm logged in it says that I am not... 🙁
Thing is, that when I tried it on my computer, it worked. Now that I try it on the web, it doesn't...