User Registration in CakePHP


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. /**
  4. * Class used for user authentication on the league website
  5. *
  6. */
  7.  
  8. class User extends AppModel
  9. {
  10. var $name = 'User';
  11.  
  12. var $validate = array(
  13. 'id' => array('rule' => 'blank',
  14. 'on' => 'create'),
  15. 'username' => array('rule' => 'alphanumeric',
  16. 'required' => true,
  17. 'message' => 'Please enter a username'),
  18. 'password' => array('rule' => array('confirmPassword', 'password'),
  19. 'message' => 'Passwords do not match'),
  20. 'password_confirm' => array('rule' => 'alphanumeric',
  21. 'required' => true)
  22. );
  23.  
  24. function confirmPassword($data, $fieldName) {
  25. $valid = false;
  26.  
  27. if ($data['password'] == Security::hash(Configure::read('Security.salt') . $this->data['User']['password_confirm'])) {
  28. $valid = true;
  29. }
  30.  
  31. return $valid;
  32. }
  33.  
  34. }
  35. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.