Guest User

Untitled

a guest
Apr 24th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. //signup.ctp
  2.  
  3. <h2>Signup</h2>
  4.  
  5. <?php $session->flash(); ?>
  6.  
  7. <?php
  8. e($form->create('Member', array('action' => 'signup'))); ?>
  9.  
  10. <h3>Login Information</h3>
  11.  
  12. <ul class="form">
  13. <li>
  14. <label for="">Email Address</label>
  15. <?php e($form->input('Member.email', array('type' => 'text', 'size' => '20', 'label' => false))); ?>
  16. </li>
  17. <li>
  18. <label for="">Password</label>
  19. <?php e($form->input('Member.password', array('type' => 'password', 'label' => false))); ?>
  20. </li>
  21. <li>
  22. <label for="">Confirm Password</label>
  23. <?php e($form->input('Member.password2', array('type' => 'password', 'label' => false))); ?>
  24. </li>
  25. </ul>
  26.  
  27. <h3>Personal Information</h3>
  28.  
  29. <ul class="form">
  30. <li>
  31. <label for="">Full Name</label>
  32. <?php e($form->input('Member.name', array('type' => 'text', 'size' => '20', 'label' => false))); ?>
  33. </li>
  34. <li>
  35. <label for="">Company Name</label>
  36. <?php e($form->input('Member.company', array('type' => 'text', 'size' => '20', 'label' => false))); ?>
  37. </li>
  38. <li>
  39. <label for="">Street Address</label>
  40. <?php e($form->input('Member.street', array('type' => 'text', 'size' => '20', 'label' => false))); ?>
  41. </li>
  42. <li>
  43. <label for="">City</label>
  44. <?php e($form->input('Member.city', array('type' => 'text', 'size' => '20', 'label' => false))); ?>
  45. </li>
  46. <li>
  47. <label for="">State</label>
  48. <?php e($form->input('Member.state', array('type' => 'text', 'size' => '20', 'label' => false))); ?>
  49. </li>
  50. <li>
  51. <label for="">Zip Code</label>
  52. <?php e($form->input('Member.zip', array('type' => 'text', 'size' => '20', 'label' => false))); ?>
  53. </li>
  54. <li>
  55. <label for="">Phone Number</label>
  56. <?php e($form->input('Member.phone', array('type' => 'text', 'size' => '20', 'label' => false))); ?>
  57. </li>
  58. </ul>
  59.  
  60. <?php e($form->submit('Sign Up Now!', array('class'=>'signup_button'))); ?>
  61.  
  62. <?php e($form->end()); ?>
  63.  
  64. //MembersController
  65. <?php
  66.  
  67. class MembersController extends AppController{
  68.  
  69. var $name = 'Members';
  70.  
  71. function beforeFilter(){
  72.  
  73. $this->Auth->userModel = 'Member';
  74. $this->Auth->allow('signup');
  75.  
  76. $this->set('area','members');
  77. $this->Auth->fields = array('username' => 'email', 'password' => 'password');
  78.  
  79. }
  80.  
  81. //show the members section
  82. function index(){
  83.  
  84. }
  85.  
  86. //We need to signup new users
  87. function signup() {
  88.  
  89. if (!empty($this->data)) {
  90.  
  91. //lets check to see if the password & confirm password are empty
  92. if(isset($this->data['Member']['password']) && isset($this->data['Member']['password2'])){
  93.  
  94. $this->data['Member']['passwordhashed'] = $this->Auth->password($this->data['Member']['password']);
  95. $this->data['Member']['password2hashed'] = $this->Auth->password($this->data['Member']['password2']);
  96.  
  97. $this->data['Member']['password'] = $this->data['Member']['passwordhashed'];
  98.  
  99. }
  100.  
  101. $this->Member->create();
  102. $this->data['Member']['joined'] = date('Y-m-d');
  103.  
  104. if ($this->Member->save($this->data)) {
  105.  
  106. $this->Session->setFlash('Your account has been created!');
  107. $this->redirect(array('action'=>'index'), null, true);
  108.  
  109. } else {
  110.  
  111. $this->Session->setFlash('You account could not be created. Try again!');
  112.  
  113. }
  114.  
  115. }
  116.  
  117. }
  118.  
  119. //Let the user login
  120. function login(){
  121.  
  122. $this->set('onLogin','true');
  123.  
  124. }
  125.  
  126. //Logout the user
  127. function logout(){
  128. $this->Session->setFlash('You\'ve been logged out!');
  129. $this->redirect($this->Auth->logout());
  130. }
  131.  
  132. }
Add Comment
Please, Sign In to add comment