Hi, I'm creating my first cakePHP driven website but am having a little problem with the user registration area. I've set up a form with the usual user signup stuff - email, name, password and password confirmation - but when the form submits it doesn't validate the password nor does it flag an error if the passwords don't compare.
I've set up the model with the validation like this: var $validate = array( 'realname' => VALID_NOT_EMPTY, 'username' => VALID_NOT_EMPTY, 'email' => VALID_EMAIL, 'password' => VALID_NOT_EMPTY, ); My view looks like this: <?php echo $html->formTag('/users/register/signup'); ?> <div class="required"> <label for="user_username">Username</label> <?php echo $html->input('User/username', array('id' => 'user_username', 'size' => '40')) ?> <?php echo $html->tagErrorMsg('User/username_taken', 'This username has already been taken. Please select another.') ?> <?php echo $html->tagErrorMsg('User/username_format', 'The username must consist of only a-z and be at least four characters long.') ?> </div> <div class="required"> <label for="user_email">Email</label> <?php echo $html->input('User/email', array('id' => 'user_email', 'size' => '40')) ?> <?php echo $html->tagErrorMsg('User/email', 'Error message for email goes here.') ?> </div> <div class="required"> <label for="user_password">Password</label> <?php echo $html->password('User/password', array('id' => 'user_password', 'size' => '40')) ?> <?php echo $html->tagErrorMsg('User/password', 'The password needs to be at least six characters long.') ?> </div> <div class="required"> <label for="user_password2">Confirm password</label> <?php echo $html->password('User/password2', array('id' => 'user_password2', 'size' => '40')) ?> <?php echo $html->tagErrorMsg('User/password2', 'Passwords do not match') ?> </div> <div class="required"> <label for="user_realname">Realname</label> <?php echo $html->input('User/realname', array('id' => 'user_realname', 'size' => '40')) ?> <?php echo $html->tagErrorMsg('User/realname', 'Error message for realname goes here.') ?> </div> <div class="submit"><?php echo $html->submit('Register'); ?></div> </form> and the 'register' action in the Users controller looks like this: function register() { $path = $stage = null; if (func_num_args()) { $path = func_get_args(); $stage = $path[0]; } switch($stage) { case 'terms': if (!empty($this->data)) { if ($this->data['User']['agree']) { $this->redirect('/users/register/signup'); } else { $this->User->invalidate('agree'); } } $this->render('register/terms'); break; case 'signup': if (!empty($this->data)) { $user = $this->User->findByUsername($this->data['User']['username']); if (!empty($user['User']['username'])) { $this->User->invalidate('username_taken'); } if (strlen($this->data['User']['username']) < 4 || !preg_match('/^([a-z]+)$/i', $this->data['User']['username'])) { $this->User->invalidate('username_format'); } if (strlen($pass) < 6) { $this->User->invalidate('password'); } if ($pass != $this->data['User']['password2']) { $this->User->invalidate('password2'); } $pass = $this->data['User']['password']; $this->data['User']['password'] = md5($pass); if ($this->User->save($this->data)) { $this->redirect('/users/register/verify'); } else { $this->data['User']['password'] = $pass; $this->validateErrors($this->User); } } $this->render('register/signup'); break; case 'verify': $this->render('register/verify'); break; } } I know I could have it as different actions, but I kind of want the url to be like 'users/register/terms', 'users/register/signup' and so on. The field 'password2' isn't in the database - it's just used to make sure they have put in the correct password. Anyway, can anyone tell me where I'm going wrong here, or possibly recommend a much better way of going about this? There are a couple other issues besides the passwords not comparing... When the save happens the 'created' field doesn't automatically get populated though the 'modified' one does - not sure why that would be. Also, I have a few more fields in the database that I want to have populated, such as the ip address they signed up from, a unique token for sending a validation email, things of that nature. Do I have to just add the information in to the controller $data array and then do the call to save? Any help would really, REALLY be appreciated!! Many thanks, Andy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~----------~----~----~----~------~----~------~--~---