Below is my controller. What I want to do is post the data from page2
to page3 using a $this->redirect(); Is this possible? Shown in BOLD in
the code is where the redirect is. Page 2 has to post to itself for
error checking but page 3 needs the post details of 2 when no errors.
Is there anyway around it without the use of sessions for example
$this->redirect(tests/page3,$this->data);? Thanks
<?php
class TestsController extends AppController {
var $name = 'Tests';
function page1() {
}
function page2() {
$this->Session->write('firstname',$this-
>data);
$this->set('myname',$this->data);
$error=false;
if(strlen($this->data['test']['surname'])==0)
$error=true;
$this->set('error',$error);
if((!$error)&&(strlen($this->data['test']
['surname'])>2)) $this->redirect('tests/page3'); //PASS $this->data to
page 3
}
function page3() {
$myfullname = $this->data['test']['name'] ."
" .$this->data['test']['surname']; //values passed from page2 when no
errors as if page2 posted directly here instead of to itself.
$this->set('fullname',$myfullname);
}
}
?>
My pages
Page1
<?php
echo $html->formTag('/tests/page2','post');
echo "Name : ";
echo $html->input('test/name');
echo $html->hidden('test/surname',array('value'=>' ')); //
Hidden field from page2, has to be here else page 2 will throw up
undefined varible errors
echo $html->submit("Next",array('class'=>'btn'));
?>
Page2
<?php
if($error) echo "Please enter in your surname";
echo $html->formTag('/tests/page2','post');
echo "Hello " .$myname['test']['name'] .". What is ur
surname?";
echo $html->input('test/surname',array('value'=>''));
echo $html->hidden('test/name'); //Hidden field from page1,
has to be here else throw up undefined varible errors
echo $html->submit("Finish",array('class'=>'btn'));
?>
Page3
<?php
echo "Welcome ".$fullname;
?>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---