Advertisement
Guest User

Josh

a guest
Feb 26th, 2008
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. <?php
  2.  
  3. class RegistrationForm extends Page {
  4.  
  5.    
  6. }
  7. class RegistrationForm_Controller extends Page_Controller {
  8.    
  9.     // Registration Form
  10.     function Form() {
  11.         return new Form($this, "Form", new FieldSet(
  12.             //List of fields
  13.             new TextField("FirstName", "First Name"),
  14.             new TextField("Surname", "Last Name"),
  15.             new TextField("UserName", "User Name"),
  16.             new EmailField("Email", "Email Address"),
  17.             new ConfirmedPasswordField("Password", "Password"),
  18.             new TextField("Address", "Address"),
  19.             new TextField("Suburb", "Suburb"),
  20.             new TextField("City", "City"),
  21.             new DateField("DateOfBirth", "Date of Birth"),
  22.             new PhoneNumberField("HomePhone", "Home phone"),
  23.             new PhoneNumberField("MobilePhone", "Mobile phone")
  24.             ), new FieldSet(
  25.                 new FormAction("register", "Register")
  26.  
  27.             ), new RequiredFields(
  28.                 "FirstName", "Surname", "UserName", "Email", "Password", "Address", "Suburb", "City", "HomePhone"
  29.                 ));
  30.     }
  31.     function register($data, $form){
  32.         // Create a new Member object and load the form data into it
  33.         $member = new Member();
  34.         $form->saveInto($member);
  35.        
  36.         // Write it to the database
  37.         $member->write();
  38.        
  39.         // Add the member to a group
  40.         if($group = DataObject::get_one('Group', "Code = 'registered-users'")){
  41.             $member->Groups()->add($group);
  42.         }
  43.        
  44.         // Redirect to Thank You page
  45.         Director::redirect('registration-successful/');
  46.     }
  47.    
  48. }
  49.  
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement