Jump to content

php error urgent help


newbie12345

Recommended Posts

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');

   }
  }

}

Link to comment
Share on other sites

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';

Link to comment
Share on other sites

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';

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.