i'm getting the following errors:
Notice 8: Undefined variable: student_info [APP\controllers
\motor_developments_controller.php, line 7]
i'm getting the same notice in \motor_developments\search.ctp as
well.
The student_info data in $this->redirect is not getting passed from
merry_parents_controller's login function to
motor_developments_controller's search function.
Does anyone know on why student_info is not getting passed? Any help
is much appreciated.
merry_parents_controller.php
function login(){
if ($this->Auth->user()){
//debug($this->Auth->user());
$this->data=$this->Auth->user();
if (!empty($this->data)){
$student_info=$this->MerryParent->Student->find('first',array(
'conditions'=>array(
'Student.merry_parent_id'=>$this->data['MerryParent']
['id'] )
) );
echo 'student info: '.$student_info;
$this->set('student_info',$student_info);
}
else{
echo 'Auth user has not been set';
}
$this->redirect(array('controller'=>'motor_developments',
'action'=>'search',$student_info));
}
}
controller:motor_development_controller.php
<?php
class MotorDevelopmentsController extends appController{
public $name='MotorDevelopments';
public function search(){
var_dump($student_info);
$x=$this->MotorDevelopment-
>find('one',array('conditions'=>array('MotorDevelopment.student_id'=>12)));
$this->set('x',$x);
$this->set(compact('x'));
}
}
?>
view: /motor_developments/search.ctp
<?php
echo 'Hello Jen<br>';
var_dump($student_info);
echo '<br>x';
var_dump($x);
?>
app_controller.php
class AppController extends Controller {
//var $components=array('Email');
var $components=array('Auth','Session','Cookie');
function beforeFilter(){
if (isset($this->Auth)){
$this->Auth->userModel=array('MerryParent');
$this->Auth-
>loginAction=array('controller'=>'merry_parents','action'=>'login');
$this->Auth->allow('*');
$this->Auth-
>loginRedirect=array('controller'=>'motor_developments','action'=>'search');
$this->Auth-
>logoutRedirect=array('controller'=>'merry_parents','action'=>'register');
//$this->Auth->deny('/motor_developments/index');
$this->Auth->authorize='controller';
}
else
$this->Session->setFlash('Auth has not been set');
}
function isAuthorized(){
return true;
}
thank you.