Hi all, Heres the scenario :
I went through the database searching for an email and found it but now i need to assign that emails user_id from the users table to the new posts user_id in the posts table - foreign key. How would i do that heres the code i have so far it works but adds 0 as the user_id for the new post. the underlined line needs fixing any help function add() { if(!empty($this->data['User']['email'])) { if ($this->User->findByemail($this->data['User']['email'])) { //$this->set new post for the user with that email; *$this->data['Post']['user_id'] = $this->User->id;* $this->User->Post->save($this->data); $this->data['Liking']['post_id'] = $this->User->Post->id; $this->User->Post->Liking->save($this->data); $this->redirect(array('controller' => 'posts', 'action' => 'index')); } else{ //$this->set('error_msg', 'This Username is Available'); $user = $this->User->save($this->data); // If the user was saved, Now we add this information to the data // and save the Profile. if (!empty($user)) { // The ID of the newly created user has been set // as $this->User->id. $this->data['Userinfo']['user_id'] = $this->User->id; // Because our User hasOne Profile, we can access // the Profile model through the User model: $this->User->Userinfo->save($this->data); $this->data['Post']['user_id'] = $this->User->id; $this->User->Post->save($this->data); $this->data['Liking']['post_id'] = $this->User->Post->id; $this->User->Post->Liking->save($this->data); $this->redirect(array('controller' => 'posts', 'action' => 'index')); } }//end if ($this->User->findByemail($this->data['User']['email'])){ }//end if(!empty($this->data['User']['email'])) { }//end add Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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