2011-09-16 22 views
0

私はAuthコンポーネントを学生の進捗状況レポートの表示にのみ使用しようとしています。他のすべてのリンクでは、認証は必要ありません。ディスカッション掲示板については、すでに別のフォーラムプラグインがあります。cakephp:登録ページの登録リンクが機能しません

ユーザーがナビゲーションバーの進捗レポートリンクをクリックすると、ユーザーは/ merry_parents/registerに誘導されます。ここで、新しいユーザーはサインアップリンクをクリックし、既存のユーザーはログインリンクをクリックします。

ただし、私の登録リンクが機能していません。私はサインアップをクリックすると、サインアップページには向かない。私は間違って何をしていますか?どんな助けでも大歓迎です。

次は私のコードです:

register.ctpあなたのMerryParentsControllerコントローラに次のコードを使用する必要があり

<?php 
    echo $this->Html->link('Sign Up','/merry_parents/signup').' for new user |'.$this->Html->link('Login','/merry_parents/login',array()).' for existing user'; 
    ?> 

merry_parents_controller.php

<?php 
    class MerryParentsController extends AppController{ 

var $name='MerryParents'; 
var $components=array('Auth','Session'); 

function beforeFilter(){ 
    //$this->Auth->authorize='actions'; 
    $this->Auth->loginAction=array('controller'=>'merry_parents','action'=>'register'); 
    //$this->Auth->loginRedirect=array('controller'=>'merry_parents','action'=>'report_card'); 

} 

function register(){ 

} 

function login(){ 
} 

function logout(){ 
} 

function signup(){ 
    if (!empty($this->data)){ 
     //$this->Auth->password($this->data['MerryParent']['password2'] used to get what the hashed password2 would look like. 
     if ($this->data['MerryParent']['password']==$this->Auth->password($this->data['MerryParent']['password2'])){ 

       $merryparent_id=$this->MerryParent->field('id', 
               array('MerryParent.name'=>$this->data['MerryParent']['name'], 
               'MerryParent.email'=>$this->data['MerryParent']['email']) 
               ); 
       echo $merryparent_id; 

       print_r($this->data); 
       if ($this->MerryParent->save($this->data))//record with $merryparent_id is updated 
        { 
        $this->Session->setFlash('You will be receiving an email shortly confirming your login and password.'); 
        $this->Auth->login($this->data); //automatically logs a user in after registration 
        $this->redirect(array('controller'=>'pages','action'=>'home')); 
        } 
       else 
        echo $this->Session->setFlash(__('Your admission could not be saved, please try again!',true)); 


      }//end if ($this->data['MerryParent']['password'].... 
      else 
       echo $this->Session->setFlash('Typed passwords did not match'); 
    }//end if (!empty($this->data)) 
} 
} 
?> 
+0

をお読みください。 –

答えて

関連する問題