PHP interesse |
|
op andere site word ik niet echt geweldig geholpen..
dus laat ik het hier maar probeeren...^^
ik heb nog nooit eerder moet cookies gewerkt,
maar ik wil mijn site cookie-enebled maken.
dus met sessies en cookies..
echter, geeft da ding een foutmelding als hij de cookie aan moet maken (setcookie):
Warning: Cannot modify header information - headers already sent by (output started at /usr/opt/usr/wa4o6920633/DOMAIN/HTML/ts/level/home.php:17) in /usr/opt/usr/wa4o6920633/DOMAIN/HTML/ts/php/login.php on line 15
Warning : Cannot modify header information - headers already sent by (output started at /usr /opt /usr /wa4o6920633 /DOMAIN /HTML /ts /level /home .php :17) in /usr /opt /usr /wa4o6920633 /DOMAIN /HTML /ts /php /login .php on line 15
dit is login.php:
<?php
if($session){
echo "You are already logged in.";
}else{
#########################################
if($_SERVER['REQUEST_METHOD'] == POST){
$username = $_POST['username'];
$password = md5($_POST['password']);
$b_cookie = $_POST['cookie'];
$query = mysql_query("SELECT * FROM `ts_members` WHERE `username`='$username' AND `password`='$password'");
$check = mysql_fetch_object($query);
if(mysql_num_rows($query) != 0 && $check->activated == 1){
if($b_cookie == ON){
setcookie("treadstone", "$username", time()+3600*24,"/",".a4o.nl",1);
}else{
$_SESSION['ts'] = $username;
}
echo "<table width=\"90%\" cellSpacing=\"0\" cellPadding=\"2\" border=\"1\" bordercolor=\"#000000\" style=\"border-collapse: collapse\" align=\"center\">";
echo "<tr><td><b>Login</b></td></tr>";
echo "<tr><td>You are logged in successfully. $b_cookie </td></tr>";
echo "</table>";
echo "<meta http-equiv=\"refresh\" content=\"1; url=index.php\">";
}else{
echo "<table width=\"90%\" cellSpacing=\"0\" cellPadding=\"2\" border=\"1\" bordercolor=\"#000000\" style=\"border-collapse: collapse\" align=\"center\">";
echo "<tr><td><b>ERROR</b></td></tr>";
echo "<tr><td>Login Failure:<br>
1. Wrong Username or Password<br>
2. Empty Fields<br>
3. Account UnActivated";
echo "</table>";
}
}else{
?><FORM ACTION="<? $_SERVER['PHP_SELF'] ?>" METHOD="POST"><?
echo "<table width=\"90%\" cellSpacing=\"0\" cellPadding=\"2\" border=\"1\" bordercolor=\"#000000\" style=\"border-collapse: collapse\" align=\"center\">";
echo "<tr><td width=\"25%\">Username:</td>";
echo "<td width=\"75%\" align=\"center\"><input type=\"text\" style=\"width: 90%\" name=\"username\"></td></tr>";
echo "<tr><td width=\"25%\">Password:</td>";
echo "<td width=\"75%\" align=\"center\"><input type=\"password\" style=\"width: 90%\" name=\"password\"></td></tr>";
echo "<tr><td width=\"25%\">Remember Me:</td>";
echo "<td width=\"75%\" align=\"center\"><input type=\"checkbox\" name=\"cookie\" value=\"ON\"></td></tr>";
echo "<tr><td colspan=\"2\"><input type=\"submit\" value=\"Login\"></td></tr>";
echo "</table>";
echo "</form>";
} }
?>
<?php if($session){ echo "You are already logged in."; }else{ ######################################### if($_SERVER['REQUEST_METHOD'] == POST){ $username = $_POST['username']; $password = md5($_POST['password']); $b_cookie = $_POST['cookie']; $query = mysql_query("SELECT * FROM `ts_members` WHERE `username`='$username' AND `password`='$password'"); if($b_cookie == ON){ setcookie("treadstone", "$username", time()+3600*24,"/",".a4o.nl",1); }else{ $_SESSION['ts'] = $username; } echo "<table width=\"90%\" cellSpacing=\"0\" cellPadding=\"2\" border=\"1\" bordercolor=\"#000000\" style=\"border-collapse: collapse\" align=\"center\">"; echo "<tr><td><b>Login</b></td></tr>"; echo "<tr><td>You are logged in successfully. $b_cookie </td></tr>"; echo "<meta http-equiv=\"refresh\" content=\"1; url=index.php\">"; }else{ echo "<table width=\"90%\" cellSpacing=\"0\" cellPadding=\"2\" border=\"1\" bordercolor=\"#000000\" style=\"border-collapse: collapse\" align=\"center\">"; echo "<tr><td><b>ERROR</b></td></tr>"; echo "<tr><td>Login Failure:<br> 1. Wrong Username or Password<br> 2. Empty Fields<br> 3. Account UnActivated"; } }else{ ?><FORM ACTION="<? $_SERVER['PHP_SELF'] ?>" METHOD="POST"><? echo "<table width=\"90%\" cellSpacing=\"0\" cellPadding=\"2\" border=\"1\" bordercolor=\"#000000\" style=\"border-collapse: collapse\" align=\"center\">"; echo "<tr><td width=\"25%\">Username:</td>"; echo "<td width=\"75%\" align=\"center\"><input type=\"text\" style=\"width: 90%\" name=\"username\"></td></tr>"; echo "<tr><td width=\"25%\">Password:</td>"; echo "<td width=\"75%\" align=\"center\"><input type=\"password\" style=\"width: 90%\" name=\"password\"></td></tr>"; echo "<tr><td width=\"25%\">Remember Me:</td>"; echo "<td width=\"75%\" align=\"center\"><input type=\"checkbox\" name=\"cookie\" value=\"ON\"></td></tr>"; echo "<tr><td colspan=\"2\"><input type=\"submit\" value=\"Login\"></td></tr>"; } } ?>
deze word geinclude in index.php.
kan iemand me mss helpen om de fout te verhelpen?
|