• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Routing Question

#1
Hi guys.

I am trying to build some sort of registration/login thing with CodeIgniter. This is my first attempt so please let me know if you spot something outside the original issue.

I have the registration form's action set to 'register/register_process'

The register_process only takes care of checking if the username already exists, and creating if the user if it doesn't exist.

At the end of the register_process method, I am telling it to load the dashboard view like so

PHP Code:
/** Username exists. */
 
     if $result == TRUE )
 
     {
 
       // some code
 
     /** Username does not exist. */
 
     else
      
{
 
       $this->register_model->create$full_name$username$password );
 
       $this->congratulations();
 
     }
 
   }
 
 }

 
 /**
   * Congratulations class.
   *
   * Notifies the user of a successful registration.
   */
 
 public function congratulations()
 
 {
 
   $data = array(
 
     'title'    => 'User successfully registered',
 
     'username' => $this->input->post'username' )
 
   );
 
   $this->load->view'templates/header'$data );
 
   $this->load->view'register/congratulations'$data );
 
   $this->load->view'templates/footer' );
 
 


The thing is, when the user gets created and the congratulations view is loaded, the URL says

localhost/sitename/register/register_process.

How do I make it show

localhost/sitename/register/congratulations

instead?
Reply

#2
Did you try a redirect to it?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(09-26-2017, 03:12 AM)InsiteFX Wrote: Did you try a redirect to it?

Oh yes.

I did something like

PHP Code:
redirect(base_url().'register/congratulations'); 

If I remember it correctly. But I wanted to pass some data in an array via

PHP Code:
$this->load->view('register/congratulations'$data); 

The other thing I read about was to try using flash sessions (forgot the correct name, although I did read the docs about it) along with the redirect to pass session variables instead.
Reply

#4
You could pass the user name to congratulations during the redirect

PHP Code:
redirect(base_url("register/congratulations/$username")); 

Revised congratulations method

PHP Code:
public function congratulations($username)
 {
   $data = array(
     'title'    => 'User successfully registered',
     'username' => $username
   
);
   $this->load->view'templates/header'$data );
   $this->load->view'register/congratulations'); //you don't have to pass $data again if it is unchanged
   $this->load->view'templates/footer' );
 
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.