I'm new to CakePHP and working on a project where I need to log the
client IP when they register. When it saves to the DB the IP doesn't
save. This is the code I currently have in the controller:

class UsersController extends AppController {

var $name = 'Users';
var $helpers = array('Html', 'Form', 'Javascript', 'Ajax', 'Cache');
var $components = array('RequestHandler');

function register()
{
        if (!empty($this->data))
        {
                $this->data['User']['creation_ip'] = $this->RequestHandler-
>getClientIP();

                $this->User->create();

                if ($this->User->save($this->data))
                {
                        $this->Session->setFlash(__("The User has been saved", 
true));
                        $this->redirect(array('action'=>'index'));
                }
                else
                {
                        $this->Session->setFlash(__("The User could not be 
saved. Please,
try again.", true));            }
        }
        $jobs = $this->User->Job->find('list');
        $this->set(compact('jobs'));
}

}

When I add the following code to the top of the method the page
redirects with the IP in the Flash message.

$this->Session->setFlash(__($this->RequestHandler->getClientIP(),
true));
$this->redirect(array('action'=>'index'));

What am I doing wrong?

--~--~---------~--~----~------------~-------~--~----~
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