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
https://forums.phpfreaks.com/topic/200972-php-error-urgent-help/
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';

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

 

 

Archived

This topic is now archived and is closed to further replies.

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