Welcome Guest, Not a member yet? Register   Sign In
Just a minor issue!
#1

[eluser]Unknown[/eluser]
Good day Codeigniter community,

I am simply another new member that discovered the potential of this frameworks not so long ago and is now 'abusing' it in his every project, haha.

Anyway I would like to hear some opinions about something I want to make.

So first thing first, I started on making a registration/signup system. I have a register controller and a function called validateRegistration in it. When the user presses the register button all of his information from the input fields goes through that function obviously. At the end I have an if/else statement to check the results of my form_validation check.

Now if I use the $this->load->view('register'); I can display the valiation errors on the page and let the user try again. But the validateRegistration still remains in the URL bar. I tried using the redirect function in the if(not) but it doesn't display the validation errors.

So is there any way I can make it work so that it displays the validation errors and the clean url without the function name segment added to it?

Thanks in advance.

Greetings,

Raziel

EDIT: If I posted this in the wrong section I am sorry and I gladly ask a moderator to move it to the right section.
#2

[eluser]Mike DeFelice[/eluser]
You should be able to do it with session flash data then when you are on the registration page after the redirect see if it exists.
Code:
check validation
$this->session->set_flashdata('error_message', 'some_value');
redirect('/register');

then
Code:
if($this->session->flashdata('error_message')) {
  echo $this->session->flashdata('error_message');
};

or you could do it in one function like

Code:
function register() {
   if($this->input->post('submit') !== FALSE) { //user tried registering
            if($this->form_validation->run() === FALSE) {
                     Display errors
               } else {
                    Add user info to database
                    Send success message
               }        
      }
$this->load->view('view_name');
}




Theme © iAndrew 2016 - Forum software by © MyBB