Hello everybody, i am totally new to Cake and am finding it quite
difficult to understand all the different parts of it. At the moment
i'm trying to make a three part user registration process, firstly
with the username and password fields, then onto details about the
user, then on to duties they wish to undertake on the site. The only
problem i am having is once the username and password are created it
creates an ID in the users tables, referenced to my other tables as
'user_id'. What i cannot quite figure out is how, once a user is
created, would i get that user_id into the duties view? What i am
doing at the moment is shown below:

        function add() {
                if (!empty($this->data)) {
                        $this->User->create();
                        if ($this->User->saveAll($this->data)) {
                                $this->Session->setFlash(__('Your Username and 
Password have been
saved', true));
                                $cookie = array();
                                $cookie['user_id'] = 
$this->Auth->user('user_id');
                                $this->Session->write('Auth.User', $cookie);
                                
$this->redirect(array('controller'=>'details','action'=>'add'));
                        } else {
                                $this->Session->setFlash(__('Your Username and 
Password could not
be saved. Please, try again.', true));
                        }
                }
        }

^users_ controller^

I then call this in the 'duties/add' view with:

                $user_id = $session->read('User_id');

                echo $form->input('user_id',array('value' => $user_id ));

The only problem with this is Cake returns a select box populated with
all of the id's in the user tables. All i want is the ID that has just
been created.

This is probably a very simple problem but i've been reading alot on
the internet and just cannot understand how to do it. Any help and
advice would be greatly appreciated!!

Yours hopefully,
Steppio

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to