Welcome Guest, Not a member yet? Register   Sign In
Validation problems
#1

[eluser]Philip Pryce[/eluser]
Well in this thread i just want to ask if i was trying to get a user to return to a form after validating their input wrong, if i just referenced the page function instead of just re-writing it again, is this technically the right way to do it?
For example, say i have these two functions in a Controller called User
Code:
function signin ($error=false, $errormsg='') {
  if ($error == true) {
    echo $errormsg;
  }
  ... lots more code to display sign in form etc
}
function proccessSignIn () {
  ... validation rules etc
  if ($this->validation->run()
    $this->signin(true, $this->validation->error_string);
    die()
  }
  ... more code if the user did meet the validation rules to sign them in
}
sorry for no tab indentations, i wrote this off the top of my head.
Thanks.
#2

[eluser]Glen Swinfield[/eluser]
It's no problem doing it that way, just remember that the $_POST data still exists so a 'refresh' would re-submit the data. If this is not going to be a problem then it's fine. Also use 'return' instead of 'die()'.




Theme © iAndrew 2016 - Forum software by © MyBB