[eluser]one4all[/eluser]
Hi all,
Someone could explain me the difference between Set_value('varname') or $this->input->post('varname') ? (if there is one...)
I mean after a success in a run validation, should we better use set_value (from form_valdation class) to retrieve data or $this->input->post (from input class) ? And why ?
Look at the 2 following examples
Ex1:
Code:
class Form extends Controller {
function index()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('varname', 'varname', 'required|xss_clean');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$mysafedata['varname']= set_value('varname');
$this->load->view('formsuccess', $mysafedata[]);
}
}
}
Ex2:
Code:
class Form extends Controller {
function index()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('varname', 'varname', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$mysafedata['varname']= $this->input->post('varname', TRUE);
$this->load->view('formsuccess', $mysafedata[]);
}
}
}
So, in this exemple, better use Ex1 or Ex2 ? Why ?
And if Ex2, can someone give me example where "xss_clean" in validation rule could be interesting ?
Thanks a lot for lighting me,
One4all