2016-09-19 149 views
0

我正在使用用戶登錄的網站上工作。 這個登錄工作之前,但現在當你按下「登錄」按鈕,你留在同一頁面,沒有任何反應。 你能幫我找到解決問題的方法嗎? 我看了無數其他的線程,但還沒有找到corredt答案的成功。CAKEPHP登錄未登錄

,如果你需要的信息不再只是問。

在此先感謝您的幫助!

Login.ctp

<script type="text/javascript"> 
$('.navbar-fixed').remove(); 
$('#side-nav').remove(); 
$('#breadcrum-nav').remove(); 

$(function() { 
    $('.col').css({ 
     'position' : 'absolute', 
     'left' : '50%', 
     'top' : '50%', 
     'margin-left' : function() {return -$(this).outerWidth()/2}, 
     'margin-top' : function() {return -$(this).outerHeight()/2} 
    }); 
}); 

</script> 
<style type="text/css"> 
    body { 
     background-image: url(../img/shattered.png); 
} 
.col { 
    background-color: rgb(255, 255, 255); 
    border-radius: 3px; 
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16); 
} 

.col h4 { 
    color: rgb(164, 165, 166); 
} 
</style> 
<div class="col l9 s12" style="border: 1px solid rgba(208, 210, 226, 0.7);"> 
<h4>MijnSDD Portal</h4> 
<?= $this->Form->create('User'); ?> 
<?= $this->Form->input('UserNAME', ['type' => 'text', 'label' => 'Gebruikersnaam']); ?> 
<?= $this->Form->input('UserWW', ['type' => 'password', 'label' => 'Wachtwoord']); ?> 
<?= $this->Form->button(__('Login <i class="material-icons right">play_arrow</i>'), ['class' => 'btn waves-effect waves-light light-blue darken-1']); ?> 
<?= $this->Form->end(); ?> 

UsersController.php

<?php 

class UsersController extends AppController { 

public function beforeFilter() { 
    parent::beforeFilter(); 
    $this->Auth->allow('logout'); 
} 

public function index() { 
    $users = $this->User->find('all'); 
    $this->set('users', $users); 
} 

public function view($id = null) { 
    $this->User->id = $id; 
    if (!$this->User->exists()) { 
     throw new NotFoundException(__('Invalid user')); 
    } 

    $this->set('user', $this->User->findByUsernr($id)); 
} 

public function add() { 
    if ($this->request->is('post')) { 
     $this->User->create(); 
     if ($this->User->save($this->request->data)) { 
      return $this->redirect(array('controller' => 'Users', 'action' => 'index')); 
     } 
    } 
} 

public function edit($id = null) { 
    $this->User->id = $id; 

    if (!$this->User->exists()) { 
     throw new NotFoundException(__('Invalid user')); 
    } 

    if ($this->request->is(array('post', 'put'))) { 
     if ($this->User->save($this->request->data)) { 
      return $this->redirect(array('controller' => 'Users', 'action' => 'index')); 
     } 
    } else { 
     $this->request->data = $this->User->findByUsernr($id); 
     unset($this->request->data['User']['UserWW']); 
    } 
} 

public function login() { 

    if ($this->request->is('post')) { 
     $this->request->data['User']['UserNAME'] = strtoupper($this->request->data['User']['UserNAME']); 
     if ($this->Auth->login()) { 
      return $this->redirect($this->Auth->redirectUrl()); 
     } 
    } 
} 

public function logout() { 
    return $this->redirect($this->Auth->logout()); 
} 
} 

AppController.php

App::uses('Controller', 'Controller'); 

class AppController extends Controller { 

public $components = array(
    'Auth' => array(
     'loginRedirect' => array(
      'controller' => 'Dashboard', 
      'action' => 'index' 
     ), 

     'logoutRedirect' => array(
      'controller' => 'Dashboard', 
      'action' => 'index' 
     ), 

     'authenticate' => array(
      'Form' => array(
       'passwordHasher' => 'Blowfish', 
       'fields' => array('username' => 'UserNAME', 'password' => 'UserWW') 
      ) 
     ) 
    ) 

); 

function beforeFilter() { 
    $user = $this->Auth->User(); 
    $naam = ""; 

    if (isset($user)) { 
     $naam .= $this->Auth->User('UserROEP'); 

     if (!empty($this->Auth->User('UserTV'))) { 
      $naam .= " " . $this->Auth->User('UserTV'); 
     } 

     $naam .= " " . $this->Auth->User('UserACHTER'); 
    } 

    $this->set('naam', $naam); 
}} 

回答

0

什麼叫 「沒有任何反應」 是什麼意思? 登錄表單是否提交?如果確實如此,結果如何?你可以檢查,如果用戶登錄成功,但沒有重定向?

我建議你安裝DebugKit得到什麼實際發生的更多信息。 https://github.com/cakephp/debug_kit/tree/2.2