Beautiful! Thanks nate.
What is the difference between Security::hash() & md5(). What size
field do I need in my database for this?
On Mar 21, 12:33 pm, "nate" <[EMAIL PROTECTED]> wrote:
> FormHelper::password doesn't have a label option, it just renders a
> password field. Use the label() method.
>
> <?=$form->create('User', array('action' => 'register')) ?>
> <?=$form->inputs(array('first_name', 'last_name', 'email',
> 'username', 'password'))?>
> <?=$form->label('confirm_password', 'Confirm your password')?><?=
> $form->password('confirm_password')?>
> <?=$form->submit('Register')?>
>
> function register() {
> if (!empty($this->data)) {
> if ($this->User->save($this->data)) {
> // OK, everything is valid
> } else {
> // Validation errors
> $this->set('errorMessage', 'Please
> correct errors below.');
> $this->render();
> }
> }
> }
>
> class User extends AppModel {
> function beforeValidate() {
> if (!$this->exists()) {
> if ($this->data['User']['confirm_password'] !=
> $this->data['User']['password']) {
>
> $this->invalidate('confirm_password');
> }
> }
> if (isset($this->data['User']['password']) &&
> !empty($this->data['User']['password'])) {
>
> $this->data['User']['password'] =
> Security::hash($this->data['User']['password']);
>
> }
> return true;
> }
>
> }
>
> On Mar 21, 1:42 pm, "xhenxhe" <[EMAIL PROTECTED]> wrote:
>
> > I'm new to this stuff. I've downloaded the latest 1.2 version this
> > morning. I want create a simple user registration form. So far I have
> > in my view:
>
> > <?=$form->create('User', array('action' => 'register'))?>
> > <?=$form->input('first_name')?>
> > <?=$form->input('last_name')?>
> > <?=$form->input('email')?>
> > <?=$form->input('username')?>
> > <?=$form->input('password')?>
> > <?=$form->password('confirm_password')?>
> > <?=$form->submit('Register')?>
>
> > I took the following function almost directly from the manual:
> > function register() {
> > if (empty($this->data)) {
> > $this->render();
> > }
> > else {
> > if ($this->User->save($this->data)) {
> > // OK, everything is valid
> > }
> > else {
> > // Validation errors
> > $this->set('errorMessage', 'Please correct
> > errors below.');
> > $this->render();
> > }
> > }
> > }
>
> > I have a few questions...
> > 1. What option do I need to pass in the the formHelper::password
> > method to get a label?
> > 2. How would I check if my password matches the password confirmation?
> > 3. How do I modify my function to md5 encrypt the password before
> > storing it?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---