| Author |  | 
      
        | emiliodeme Newbie
 
  
 
 Joined: 03 May 2012
 Online Status: Offline
 Posts: 9
 | 
          Hi there!
           | Posted: 17 May 2012 at 10:35pm | IP Logged |   |  
           | 
 |  
 Using this example Logging in Programmatically I made a custom login for my website, but using correct authentication data it returns the following message "Authentication failed".
 
 What can it be?
 
 int.php code
 
 
| Quote: 
 
    
    | 
      
       | <?php // Example of logging into WebMail account using email and password for incorporating into another web application
 
 // determining main directory
 defined('WM_ROOTPATH') || define('WM_ROOTPATH', (dirname(__FILE__).'/'));
 
 // utilizing WebMail Pro API
 include_once WM_ROOTPATH.'libraries/afterlogic/api.php';
 if (class_exists('CApi') && CApi::IsValid())
 {
 // data for logging into account
 $sEmail = $_POST['email'];
 $sPassword = $_POST['password'];
 
 // Getting required API class
 $oApiWebMailManager = CApi::Manager('webmail');
 
 // attempting to obtain object for account we're trying to log into
 $oAccount = $oApiWebMailManager->LoginToAccount($sEmail, $sPassword);
 if ($oAccount)
 {
 // populating session data from the account
 $oAccount->FillSession();
 
 // redirecting to WebMail
 $oApiWebMailManager->JumpToWebMail('../webmail.php?check=1');
 }
 else
 {
 // login error
 echo $oApiWebMailManager->GetLastErrorMessage();
 }
 }
 else
 {
 echo 'WebMail API not allowed';
 }
 |  |  |  
 form code:
 ps: adress was hidden, but int.php path is correct.
 
 
| Quote: 
 
    
    | 
      
       | <?php
 }
 
 $title = apply_filters('widget_title', $instance['title'] );
 if ( isset($instance['id']) ) $id = $instance['id'];
 $sEmail = __('Login *', 'brave');
 $sPassword = __('Senha *', 'brave');
 $entrar = __('Entrar', 'brave');
 $erro = __('Erro! Login ou senha incorretos.', 'brave');
 
 echo $before_widget;
 if ( $title ) echo $before_title . $title . $after_title;
 echo '<div><form id="quickcontact" method="post" action="http://www.*********************/mail/int.php">
 <input type="text" name="name" id="quickcontact_name" class="requiredfield" onFocus="if(this.value == \''.$sEmail.'\') { this.value = \'\'; }" onBlur="if(this.value == \'\') { this.value = \''.$sEmail.'\'; }" value=\''.$sEmail.'\'/>
 <input type="password" name="email" id="quickcontact_email" class="requiredfield" onFocus="if(this.value == \''.$sPassword.'\') { this.value = \'\'; }" onBlur="if(this.value == \'\') { this.value = \''.$sPassword.'\'; }" value=\''.$sPassword.'\'/>
 <button type="submit" name="submit" value="Enter">'.$entrar.'</button>
 <span class="errormessage">'.$erro.'</span>
 </form></div>';
 |  |  |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | daisyemma Newbie
 
  
  
 Joined: 18 May 2012
 Online Status: Offline
 Posts: 1
 | 
          The content is professional,could you explain again for me?
           | Posted: 18 May 2012 at 1:51am | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |       | 
       
       
        |  | 
        | emiliodeme Newbie
 
  
 
 Joined: 03 May 2012
 Online Status: Offline
 Posts: 9
 | 
          
           | Posted: 18 May 2012 at 6:19am | IP Logged |   |  
           | 
 |  
| daisyemma wrote: 
 
    
    | 
      
       | The content is professional,could you explain again for me? |  |  |  
 To simplify, I am using this code inside a widget inside wordpress... it's a php form following the instructions of Logging in programmatically.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | emiliodeme Newbie
 
  
 
 Joined: 03 May 2012
 Online Status: Offline
 Posts: 9
 | 
          Problem solved, code error, the name field was pointing incorrect values. THey are red colored bellow... the first one was supposed to be "email" and the second one "password".
           | Posted: 21 May 2012 at 1:10pm | IP Logged |   |  
           | 
 |  
 Thanks,
 Emilio
 
 
 
[/QUOTE]| Quote: 
 
    
    | 
      
       | <?php
 }
 
 $title = apply_filters('widget_title', $instance['title'] );
 if ( isset($instance['id']) ) $id = $instance['id'];
 $sEmail = __('Login *', 'brave');
 $sPassword = __('Senha *', 'brave');
 $entrar = __('Entrar', 'brave');
 $erro = __('Erro! Login ou senha incorretos.', 'brave');
 
 echo $before_widget;
 if ( $title ) echo $before_title . $title . $after_title;
 echo '<div><form id="quickcontact" method="post" action="http://www.*********************/mail/int.php">
 <input type="text" name="name" id="quickcontact_name" class="requiredfield" onFocus="if(this.value == \''.$sEmail.'\') { this.value = \'\'; }" onBlur="if(this.value == \'\') { this.value = \''.$sEmail.'\'; }" value=\''.$sEmail.'\'/>
 <input type="password" name="email" id="quickcontact_email" class="requiredfield" onFocus="if(this.value == \''.$sPassword.'\') { this.value = \'\'; }" onBlur="if(this.value == \'\') { this.value = \''.$sPassword.'\'; }" value=\''.$sPassword.'\'/>
 <button type="submit" name="submit" value="Enter">'.$entrar.'</button>
 <span class="errormessage">'.$erro.'</span>
 </form></div>';
 |  |  |  | 
       
        | Back to Top |     | 
       
       
        |  |