Jump to content

spinanicky

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

spinanicky's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey im new here so i dont know if this is in the right thread.. im sure you guys will solve my problem quickly though. Basically whether i use cookies or session() i get this error: [b]Cannot send session cache limiter - headers already sent (output started at E:\Program Files\wamp\www\visgrave\login.php:2) in[/b] its basically just a login script for session tracking. here is the code This is on the main page: [code] <?php //----------------------------USER LOGIN------------------------------------------------- if(!isset($id)){ echo ' <form  name="login" action="login.php"  method="post"> <input name="username" size="15" type="text" value=""><br>       <input name="password" type="password" value="" size="15">       <input type="submit" value="Log In">   </form> ';   }   //-------------------------LOGED IN DISPLAY DETAILS--------------------------------------   else{     $connection = mysql_connect("localhost","root","password") or die("could not connect to server");   mysql_select_db("vis",$connection) or die("could not select DB");     $sql = "SELECT activation FROM pending where username = '$username'";   $results = mysql_query($sql);   while($row = mysql_fetch_array($results)){     $activation = $row["$activation"];   }       echo "<p class=login>Username: $username </p>";   echo "<p class='status'>your status is:";   if ($activation = 0) echo 'Awaiting activation code.</p>';   elseif ($activation = 1) echo 'Active</p>';   elseif ($activation = 2) echo 'Banned</p>';   elseif ($activation = 3) echo 'Admin</p>';   }   //-------------------------------END OF MEMBER INFO---------------------------------------//     ?> [/code] This should start the session (login.php) [code]   <?php session_start(); header("Cache-control: private"); $connection = mysql_connect("localhost","root","password") or die ("could not connect to the server"); $db = mysql_select_db("vis", $connection) or die ("could not connect to database");     $sql = "SELECT * FROM pending WHERE username='$username' and password='$password'";   $results = mysql_query($sql, $connection) or die ("couldnt execture query");   $num = mysql_numrows($results);     //echo "$num";   //INCORRECT AUTHENTICATION--------------------------   if ($num == 0) echo 'The username or password provided was incorrect, please try again';   //CORRECT AUTHENTICATION-----------------------------    else {     $row = mysql_fetch_array($results);   $activation = $row["activation"]; //echo 'test $activation <br>'; if ($activation == 0) {echo '<p> Please check your email and activate your account using your activation code. Remember that that after you have done this it may take up to another 24 hours untill your account is activated. </p>';} elseif (($activation == 1)||($activation == 2)||($activation == 3)){ $userip = getenv("REMOTE_ADDR"); if($userip == "193.171.151.19") $time = '600'; else $time = '1800'; //echo '$time<br>'; //setcookie("id",$username,time()+1800,"/","",0); $_SESSION['userid'] = $row['username']; echo 'Login succesful. Please wait to be redirected<br>'; } else echo 'error'; }     ?> [/code] The first code is set up to use the cookie thats why ther is the if(!$id) etc  but that doesnt make a difference to the problem i have. thanks for your help Nicky
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.