Welcome Guest, Not a member yet? Register   Sign In
How to show a view and process it from within one function?
#1

[eluser]Procode[/eluser]
I am slightly stuck with this issue. I want to load the view and process the data from within one function. However it doesn't seem to work when I do the following:

Code:
public function login(){
  $submit = $this->input->post('submit');
  if(!isset($submit)){
   //Show the view
  } else {
   //Process the form
  }
}

The form never submits. Is there a better way to do this?
Thank you!
#2

[eluser]CroNiX[/eluser]
because $this->input->post() will always return a value, so isset() will always be TRUE. It will return boolean FALSE if it is NOT set, if it is it will return the value.

Code:
$submitted = $this->input->post('submit');
if ($submitted !== FALSE) //Strict check for boolean false
{
  //form has been submitted
}




Theme © iAndrew 2016 - Forum software by © MyBB