newbie12345 Posted May 7, 2010 Share Posted May 7, 2010 my problem is that im trying to register a session but im getting an error the error im getting is u have been logged in successfully Deprecated: Function session_register() is deprecated in C:\wamp\www\music website\login.php on line 25 Deprecated: Function session_register() is deprecated in C:\wamp\www\music website\login.php on line 26 can anyone help me with my error include ('connect.php'); $user = $_POST['u_name']; $pass = $_POST['pwd']; if(!$user){ echo "please enter your username. <br>"; } if(!$pass){ echo "please enter your password"; } if ($user && $pass){ $sql= ("SELECT * FROM user_accounts WHERE username = '$user' AND password = '$pass'"); $res = mysql_query($sql); $count = mysql_num_rows($res); if ($count ==0){ echo "ur user name or password may be incorrect! try again"; } ELSE { if ($count ==1){ $row = mysql_fetch_array($res); echo "u have been logged in successfully"; session_register('user'); session_register('pass'); } } } Quote Link to comment Share on other sites More sharing options...
Alex Posted May 7, 2010 Share Posted May 7, 2010 You should not be using session_register, as the notice states it's depreciated and has been for quite some time. Instead use the $_SESSION array. It is also important to note that you must start the session on every page (preferably at the top) to access the values in this array. session_start(); // Start the session ... $_SESSION['var'] = 'val'; Quote Link to comment Share on other sites More sharing options...
newbie12345 Posted May 7, 2010 Author Share Posted May 7, 2010 let me get this right im starting the session at the top of the page with session_start(); // Start the session and the creating a session variable with this $_SESSION['var'] = 'val'; so if i want to create a session after the user is login in wat am i doing is it this echo "u have been logged in successfully"; $_SESSION['username'] = 'user'; $_SESSION['password'] = 'pass'; 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.