tags:

views:

144

answers:

3
function procLogin( $user, $pass, $remember, $hostname, $domainame )
{ 
  global $session, $form;

  $retval = $session->login( $user, $pass, $remember );
  if ( $retval )
  {
    if ( $session->userlevel == 9 )
      if ( $session->isAdmin() ) 
        return ( array( 
          $session->userlevel, $session->userid 
        ) );
  } else { 
    $process = new process( );
    //process->s_Host('domain.com');
    //$process->s_Domain('domain.com');
    $process->s_Host( $hostname );
    $process->s_Domain( $domainname );
    $process->s_processSecure( false );

    $process->s_User( $user );
    $process->s_Pass( $pass );
    // First check we actually have a username and password set inside the process object.
    if ( $process->g_User() && $process->g_Pass() )
    {
      if ( $process->processConn() )
      {
        if ( $process->processBind() )
        {
          return 'google';
        }
      }
    }
  }
}

My problem is if the login is false, why does it not turn towards else condition....

if i remove the code inside else part and put return 'no' it does work.... i just want to know why the code inside the else part does not execute

+7  A: 

$session->login(... must somehow always evaluate to true. You would probably be better off posting the code of the login method.

karim79
My problem is if the login is false, why does it not turn towards else condition....
Try assigning false to $retval without the call to login and see if that works.
karim79
+1 This is going to be it, I'm willing to bet. $retval is evaluating to TRUE every time.
Peter Bailey
Not like that Karim.... if i remove the code inside else part and put return 'no' it does work.... i just want to know why the code inside the else part does not execute.
+1  A: 

Without a specific error or details of the implementation, or a hint that the PHP runtime or builtin or library is broken ...

This looks like a case of go back, check, debug.

Aiden Bell
My problem is if the login is false, why does it not turn towards else condition....
Becuase, it is not false, or your control flow is poor. The if statement processing is not broken.
Aiden Bell
+2  A: 

Maybe login is returning "false" as a string? It is evaluating to true because it is not null.

tpower