Jump to content

[RESOLVED] Fatal error: Call to a member function login() on a non-object


Jumpy09

Recommended Posts

RESOLVED:  Forgot to re-include the session.php when I changed how the page was called.  Simple things like that, but it's a learning experience.

 

Problem:

 

Error: Fatal error: Call to a member function login() on a non-object in ***mysite***/process.php on line 60

   function procLogin(){
      global $session, $form;
      /* Login attempt */
      $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember'])); /*** Line 60 ***/
      
      /* Login successful */
      if($retval){
          header("Location: ".$session->referrer);
      }
      /* Login failed */
      else{
         $_SESSION['value_array'] = $_POST;
         $_SESSION['error_array'] = $form->getErrorArray();
         header("Location: ".$session->referrer);
      }
   }

 

So let me explain a few more things to give you a rough idea of the site layout.

I'm using a $_GET method of switching between pages ($include) depending on which page is clicked.  The way I have done this the header is always showing.

Since the Login Script for process.php uses ""header("Location: ".$session->referrer);"", I cannot call to the process.php page through the same method.  I have instead had it called to the process.php page by itself, which is now giving me this error.

 

I dunno what the error means, all I know is it has something to do with the posting methods.  Any ideas?

You're attempting to use $session as though it's an object.  PHP is telling you it isn't an object.  What is $session supposed to be?

 

Also, never use global variables.  Functions and methods have argument lists for a reason, one of which is ensuring that the parameters that are passed in and used in the function/method actually exist.  Does $session and/or $form actually exist at the time when you attempt to use them?

It means $session isn't an object -- where is it declared?

 

The Include for session.php was included in the header.php which is a constant.  When I changed how the process.php was called, I forgot to add the include("session.php"); back to the process.php.  Since I just woke up, I'm going to let myself slide on that one.  But now everything works properly, yay!

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.