SyncViews Posted April 13, 2008 Share Posted April 13, 2008 Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 login.php <this is the page i'm displaying that gives the error... <?php $page_name = 'Login'; $root_level= ''; include('include/config.php');//passwords etc include('include/start.php'); if(!isset($_POST["stay"])) $_POST["stay"] = 0; if(isset($_POST["name"]) && isset($_POST["pass"])) { //shouldn't be here if($user_loggedin) header('location:' . $url_root); //login else { $login = login($_POST["name"], $_POST["pass"], $_POST["stay"]); $smarty->assign("LOGIN_RESULT", $login); $smarty->display('header.tpl'); $smarty->display('login.tpl'); $smarty->display('footer.tpl'); } } //no data... else header('location:' . $url_root); ?> start.php <?php session_start(); //get functions include ($root_level . 'include/functions.php'); //connect $con = mysql_connect($sql_host, $sql_user, $sql_pass) or exit('Failed to connect to database: ' . mysql_error()); mysql_select_db($sql_db, $con); $style = $def_style; //only if it's set and true... if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"]) { $user_loggedin = true; $user_name = $_SESSION["user_name"]; $user_id = $_SESSION["user_id"]; $user_last = $_SESSION["user_last"]; $user_pms = 0; } else { $user_loggedin = false; $user_name = "Visitor"; $user_id = 0; $user_last = 0; $user_pms = 0; } ...template stuff doesn't touch sessions... ?> functions.php <?php //returns non-zero on fail function login($name, $pass, $stay) { global $smarty, $user_loggedin, $user_name, $user_id, $user_pms, $user_last, $domain; if(!valid($name, "name")) return 1; if(!valid($pass, "password")) return 2; //check user exists + correct password $query = mysql_query('SELECT user_id, password, salt, banned, last FROM users WHERE username="'.$name.'"') or exit(mysql_error); if(mysql_num_rows($query) != 1)return 3; $data = mysql_fetch_array($query); if($data["banned"]) return 5; if(md5($data[salt] . $pass) != $data["password"])return 4; //set varibles $user_loggedin = true; $user_name = $name; $user_id = $data["user_id"]; $user_pms = 0; $user_last = $data["last"]; $_SESSION["loggedin"] = 1; $_SESSION["user_name"] = $data["username"]; $_SESSION["user_id"] = $data["user_id"]; $_SESSION["user_last"] = $data["last"]; //assign smarty varibles $smarty->assign('USER_LOGGEDIN', $user_loggedin); $smarty->assign('USER_NAME', $user_name); $smarty->assign('USER_ID', $user_id); $smarty->assign('USER_LAST', date("H:i:s d-m-y",$data["last"])); $smarty->assign('USER_PMS', $user_pms); //stay logged in if($stay) { $cookie['username'] = $name; $cookie['password'] = $pass; setcookie('login', serialize($cookie), time()+days(60), '/','.' . $domain); } //update last login time mysql_query('UPDATE users SET last='.time().' WHERE user_id='.$user_id); return 0; } ?> Quote Link to comment Share on other sites More sharing options...
Gamic Posted April 13, 2008 Share Posted April 13, 2008 Do the inputs on the form you use to login have the name attribute set? (I was getting this the other day with only the id attribute set) Quote Link to comment Share on other sites More sharing options...
SyncViews Posted April 13, 2008 Author Share Posted April 13, 2008 All have there names set... <form action="{$URL_ROOT}login.php" method="post"> <label for="login_name">Username:</label><input type="text" name="name" id="login_name" /> <label for="login_pass">Password:</label><input type="password" name="pass" id="login_pass" /> <label for="login_stay">Stay logged in:</label> <input type="checkbox" name="stay" id="login_stay" /> <input type="submit" value="Login" /> </form> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.