help getting freaky error

hyeclass

New Member
Messages
348
Reaction score
0
Points
0
PHP:
<?
if ($logged[gebruiker])
{
setcookie("id", 2132421,time()+(60*60*24*5), "/", "");
setcookie("pass", loggedout,time()+(60*60*24*5), "/", "");
echo ("You are now logged out! <br>");
header('Location: index.php');
}
else
{
$loginform = "<form name=\"form1\" method=\"post\" action=\"\">
  <table width=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
    <tr>
      <td>Gebruikersnaam:</td>
      <td><input name=\"username\" type=\"text\" id=\"usern\"></td>
    </tr>
    <tr>
      <td>Wachtwoord</td>
      <td><input name=\"pass\" type=\"text\" id=\"pass\"></td>
    </tr>
  </table>
  <input type=\"submit\" name=\"Submit\" value=\"Submit\">
</form>";
echo "$loginform";
if ($_POST[Submit])
{
$query = mysql_query("SELECT * FROM users WHERE gebruiker = '$username'") or die(mysql_error());
$user = mysql_fetch_array($query);
$username = $_POST['username'];
$pass = md5($_POST['pass']);
if (!$user[pass] == $pass)
{
echo "Er klopt iets niet met de ingegeven data<br>";
}
else
{
$query = mysql_query("SELECT * FROM users WHERE gebruiker = '$username'") or die(mysql_error());
$user = mysql_fetch_array($query);
setcookie("id", $user[id],time()+(60*60*24*5));
setcookie("pass", $pass,time()+(60*60*24*5)); 
echo "je bent nu ingelogd";
}
}
}
?>

Warning: Cannot modify header information - headers already sent by (output started at /home/kaotix/domains/kaotix-crew.net/public_html/bugz.inc/index.php:5) in /home/kaotix/domains/kaotix-crew.net/public_html/bugz.inc/loginform.php on line 39

Warning: Cannot modify header information - headers already sent by (output started at /home/kaotix/domains/kaotix-crew.net/public_html/bugz.inc/index.php:5) in /home/kaotix/domains/kaotix-crew.net/public_html/bugz.inc/loginform.php on line 40

i'm getting that erro but cant see why and there is no whitespace in my code after the or befor the php tags anywhere if you want i can post the index file too

thank you in advance
 

lambada

New Member
Messages
2,444
Reaction score
0
Points
0
I tink that code is valid except for this:
Code:
setcookie("id", 2132421,time()+(60*60*24*5), "/", "");
setcookie("pass", loggedout,time()+(60*60*24*5), "/", "");
echo ("You are now logged out! <br>");
header('Location: index.php');
Try moving the header() to above the echo().
I can't see any real problem with your code there, but I suspect it is to do with the nested if()statements, try using either elseif() statements, or use switch with case statements.

I prefer the latter as it creates what I feel is more readable code, but the choice is yours.
 

hyeclass

New Member
Messages
348
Reaction score
0
Points
0
you are right i think its best to replace it with an echo of a html redirect :D i'll let you know what happened
 

hyeclass

New Member
Messages
348
Reaction score
0
Points
0
it turns out thats not the cause at all. :D
in my index.php i had liek this :
-html
php < my include config was here
-html

-html < shoudl be here include("config.php") or whatever :D
php
-html
 
Top