I am trying to implement "signin or signup" form in codeigniter.so its one form which accepts email and password and POST to below controller.
Expectation : check if email is duplicate, if exists, Post email,password to login method, else post email,password to register method.
Current behaviour: it checks for duplicate and posting validate error as email already exits and never login.
Here is my user controller logic
public function index()
{
$email = $this->input->post('email');
$password = $this->input->post('password');
$this->form_validation->set_rules('email', 'Email', 'is_unique[user.email]');
if( $this->form_validation->run() === FALSE)
{
$this->login($email,$password);
}
else { $this->register($email,$password);}
}
login()
function which isn't here. also typically in ux there is a login page and a sign up page that are separated via link - we don't always want to assume that the user wants to create an account by attempting to login. imagine a scenario, which happens quite often, where a user mistypes or enters the wrong email... i also hope yourlogin()
andregister()
methods are private as they reside in the controller and aren't meant to be used via a url. – Alex