Welcome Guest, Not a member yet? Register   Sign In
help with register and login in same controller
#1

[eluser]dadamssg87[/eluser]
I'm trying to figure out how to set this up. I want a web page where you have a box to register or if you have already registered theres a login form to the right of it.

How do i have two form validations in the same controller?
#2

[eluser]Christophe28[/eluser]
Can't you give an ID to the form validation or something like that?
#3

[eluser]dadamssg87[/eluser]
not to my knowledge. I have two different forms on the same page and have the <?php echo validation_errors(); ?> code at the top of each one. If i submit one form with errors the validation errors messages show up on both forms.

No clue how to get around this.
#4

[eluser]nuwanda[/eluser]
Two forms in one view is the question.

Each form should access its own method in the controller. Each method accesses its own validation instance.

/user/register
/user/login

Code:
function login(){
  validate data
  if errors(load view with errors)
}

function register(){
  validate data
  if errors(load view with errors)
}

Both call the same view. The view displays the validation errors for each form. Only one form at a time can have errors as it was generated by its own controller method. Obviously, the fields in the login form and the register form should be named differently so that the errors don't get displayed in the wrong form.

There should be no conflict.




Theme © iAndrew 2016 - Forum software by © MyBB