Hey Boys, Hi Girls,
In Bottom you can see my RegistrationForm.php. Its simple but it works. When I have a group called "UserGruppe", then visitors can register and there were added to the DataBase in "member".
BUT, when there is someone, who registers with an email adress that allread exists in "member" (there is a registered member with this email adress), then the new FirstName und Surname were UPDATED at that member, and there is no new member.
I want to add an "email check", so a email adress can only have one user.
i realy dont know how to do this in SS. i think i have to make a Query, if the email already exists, but dont know how.
HERE THE FILE:
#####################################
<?
class RegistrationForm extends Page {
}
class RegistrationForm_Controller extends Page_Controller {
function Form() {
return new Form($this, "Form", new FieldSet(
// List the your fields here
new TextField("FirstName", "Vorname"),
new TextField("Surname", "Nachname"),
new EmailField("Email", "Email Addresse")
), new FieldSet(
// List the action buttons here
new FormAction("doform", "Registrieren")
), new RequiredFields(
// List the required fields here: "Email", "FirstName"
"Email", "FirstName", "Surname"
));
}
function doform($data, $form) {
// Create a new Member object and load the form data into it
$member = new Member();
$form->saveInto($member);
// Write it to the database. This needs to happen before we add it to a group
$member->write();
// Add the member to group. (Check if it exists first)
if($group = DataObject::get_one('Group', "Code = 'UserGruppe'")) {
$member->Groups()->add($group);
}
// Redirect to a page thanking people for registering
Director::redirect('jobangebote/');
}
}
?>
##########################################
p.s.
maybe someone can help me to tell me, whats the best way to protect pages, i mean certain pages should be only visible from logged in users and how to make a form für the users to UPDATE THEIR MEMBER DATA???
TY TY TY if there is any help :D