Welcome Guest, Not a member yet? Register   Sign In
validation class with multiple pages
#2

[eluser]xwero[/eluser]
If you want to redirect your page you have to process the $_POST data before you redirect

Code:
$this->load->library('validation');

if ($this->validation->run() == FALSE) {
//show errors
} else {
// process $_POST page 1
//to next page
$this->page2();
}

You could create a function to check if the user can proceed to the next page or not

Code:
function page1(){
$_POST['page'] = 1;
$_POST['redirect'] = 2;
_nextpage($_POST);
}
function page2(){
$_POST['page'] = 2;
$_POST['redirect'] = 3;
_nextpage($_POST);
}
function page3(){
$_POST['page'] = 3;
$_POST['redirect'] = 4;
_nextpage($_POST);
}
function page4(){
$_POST['page'] = 4;
$_POST['redirect'] = 4;
_nextpage($_POST);
}

function _nextpage($post)
{
$this->load->library('validation');
// validation rules
switch($post['page'])
{

}

if ($this->validation->run() == FALSE) {
//show errors
switch($post['page'])
{

}
} else {
// process $_POST
switch($post['page'])
{

}
//to next page
redirect('page'.$post['redirect'], 'location');
}
}
it's a quick idea how you would get this working but it's far from finished, for instance it will be difficult to show the errors. Maybe the function should output an empty string or an error string which you check in the page functions and do the redirect there.


Messages In This Thread
validation class with multiple pages - by El Forum - 09-12-2007, 04:18 AM
validation class with multiple pages - by El Forum - 09-12-2007, 04:56 AM
validation class with multiple pages - by El Forum - 09-12-2007, 06:28 AM
validation class with multiple pages - by El Forum - 09-12-2007, 06:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB