I am more than willing to pay for this answer as I have already pulled my hair out trying to fix it myself lol. You can see the error here This is the code (lines 1-26): <? include("database.php"); include("form.php"); class Session { var $username; //Username given on sign-up var $userid; //Random value generated on current login var $userlevel; //The level to which the user pertains var $time; //Time user was last active (page loaded) var $logged_in; //True if user is logged in, false otherwise var $userinfo = array(); //The array holding all user info var $url; //The page url current being viewed var $referrer; //Last recorded site page viewed var $ip; //Remote IP address function Session(){ $this->ip = $_SERVER["REMOTE_ADDR"]; $this->time = time(); $this->startSession(); } function startSession(){ global $database; session_start(); Please let me know if you can help me with this Regards, H.
Means that something was already outputted to the browser. Can you post the entire contents of session.php? Use the php or code tags so that it is formatted properly on the forum.
<? include("database.php"); include("form.php"); class Session { var $username; //Username given on sign-up var $userid; //Random value generated on current login var $userlevel; //The level to which the user pertains var $time; //Time user was last active (page loaded) var $logged_in; //True if user is logged in, false otherwise var $userinfo = array(); //The array holding all user info var $url; //The page url current being viewed var $referrer; //Last recorded site page viewed var $ip; //Remote IP address function Session(){ $this->ip = $_SERVER["REMOTE_ADDR"]; $this->time = time(); $this->startSession(); } function startSession(){ global $database; session_start(); /* Determine if user is logged in */ $this->logged_in = $this->checkLogin(); /* Set referrer page */ if(isset($_SESSION['url'])){ $this->referrer = $_SESSION['url']; }else{ $this->referrer = "/"; } /* Set current url */ $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF']; } function checkLogin(){ global $database; /* Check if user has been remembered */ if(isset($_COOKIE['cookname'])){ $this->username = $_SESSION['username'] = $_COOKIE['cookname']; } if(isset($_SESSION['username'])){ if($database->confirmUserName($_SESSION['username']) != 0){ unset($_SESSION['username']); return false; } $this->userinfo = $database->getUserInfo($_SESSION['username']); $this->username = $this->userinfo['username']; return true; } else{ return false; } } function login($subuser, $subpass, $subremember){ global $database, $form; unset($form->errors); /* Checks if this IP address is currently blocked*/ $result = $database->confirmIPAddress($this->ip); if($result == 1){ $error_type = "access"; $form->setError($error_type, "Access denied for ".TIME_PERIOD." minutes"); } /* Return if form errors exist */ if($form->num_errors > 0){ return false; } $error_type = "attempt"; /* Username and password error checking */ if(!$subuser || !$subpass || strlen($subuser = trim($subuser)) == 0){ $form->setError($error_type, "Username or password not entered"); } if($form->num_errors > 0){ return false; } /* Checks that username is in database and password is correct */ $subuser = stripslashes($subuser); $result = $database->confirmUserPass($subuser, $subpass); if($result == 1){ $form->setError($error_type, "Invalid username or password."); $database->addLoginAttempt($this->ip); } if($form->num_errors > 0){ return false; } /* Username and password correct, register session variables */ $this->userinfo = $database->getUserInfo($subuser); $this->username = $_SESSION['username'] = $this->userinfo['username']; /* Null login attempts */ $database->clearLoginAttempts($this->ip); if($subremember){ setcookie("cookname", $this->username, time()+COOKIE_EXPIRE, COOKIE_PATH); } /* Login completed successfully */ return true; } function logout(){ global $database; if(isset($_COOKIE['cookname'])){ setcookie("cookname", "", time()-COOKIE_EXPIRE, COOKIE_PATH); } unset($_SESSION['username']); $this->logged_in = false; } }; /* Initialize session object */ $session = new Session; /* Initialize form object */ $form = new Form; ?> Code (markup): Thanks in advance. H.
Try putting include("form.php"); Code (markup): below the: class Session { var $username; //Username given on sign-up var $userid; //Random value generated on current login var $userlevel; //The level to which the user pertains var $time; //Time user was last active (page loaded) var $logged_in; //True if user is logged in, false otherwise var $userinfo = array(); //The array holding all user info var $url; //The page url current being viewed var $referrer; //Last recorded site page viewed var $ip; //Remote IP address function Session(){ $this->ip = $_SERVER["REMOTE_ADDR"]; $this->time = time(); $this->startSession(); } function startSession(){ global $database; session_start(); /* Determine if user is logged in */ $this->logged_in = $this->checkLogin(); /* Set referrer page */ if(isset($_SESSION['url'])){ $this->referrer = $_SESSION['url']; }else{ $this->referrer = "/"; } /* Set current url */ $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF']; } function checkLogin(){ global $database; /* Check if user has been remembered */ if(isset($_COOKIE['cookname'])){ $this->username = $_SESSION['username'] = $_COOKIE['cookname']; } if(isset($_SESSION['username'])){ if($database->confirmUserName($_SESSION['username']) != 0){ unset($_SESSION['username']); return false; } $this->userinfo = $database->getUserInfo($_SESSION['username']); $this->username = $this->userinfo['username']; return true; } else{ return false; } } function login($subuser, $subpass, $subremember){ global $database, $form; unset($form->errors); /* Checks if this IP address is currently blocked*/ $result = $database->confirmIPAddress($this->ip); if($result == 1){ $error_type = "access"; $form->setError($error_type, "Access denied for ".TIME_PERIOD." minutes"); } /* Return if form errors exist */ if($form->num_errors > 0){ return false; } $error_type = "attempt"; /* Username and password error checking */ if(!$subuser || !$subpass || strlen($subuser = trim($subuser)) == 0){ $form->setError($error_type, "Username or password not entered"); } if($form->num_errors > 0){ return false; } /* Checks that username is in database and password is correct */ $subuser = stripslashes($subuser); $result = $database->confirmUserPass($subuser, $subpass); if($result == 1){ $form->setError($error_type, "Invalid username or password."); $database->addLoginAttempt($this->ip); } if($form->num_errors > 0){ return false; } /* Username and password correct, register session variables */ $this->userinfo = $database->getUserInfo($subuser); $this->username = $_SESSION['username'] = $this->userinfo['username']; /* Null login attempts */ $database->clearLoginAttempts($this->ip); if($subremember){ setcookie("cookname", $this->username, time()+COOKIE_EXPIRE, COOKIE_PATH); } /* Login completed successfully */ return true; } function logout(){ global $database; if(isset($_COOKIE['cookname'])){ setcookie("cookname", "", time()-COOKIE_EXPIRE, COOKIE_PATH); } unset($_SESSION['username']); $this->logged_in = false; } } Code (markup): And you don't need a semicolon while closing function/class.
Thanks, it no longer gives the previous errors but now says: Fatal error: Cannot redeclare class Form in /home/alsabah/public_html/4dvd.com/include/form.php on line 3
Paste form.php as well as database.php (you can obviously hide all passwords and connection details of course) codes if you can. This would let us know what is inside them.
Moved both, still getting header error: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/alsabah/public_html/4dvd.com/include/session.php:1) in /home/alsabah/public_html/4dvd.com/include/session.php on line 22 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/alsabah/public_html/4dvd.com/include/session.php:1) in /home/alsabah/public_html/4dvd.com/include/session.php on line 22
I reckon that you use session_start(); What you need to do is to make sure that this code is the first one. THe thing here is that you cannot output any text in front of session_start(); code.
I tried to move session start to the begining of the code, but this just left me with a blank page on load.
Try to remove the session_start() from the form.php and database.php if its there. Or if its require on both/any file(s), then remove it from class function. hope it helps..
I still cannot seem to get it lol. Would a coder please contact me and let me know how much it would cost me for them to fix it. Thanks in advance, H.