我有一个表格。在那里您应该能够注册新用户。但它也应该检查用户名是否已经存在。如果我们假设一个人想要注册自己但他的用户名已经存在。所以我们提出了一个“用户名已经存在”的文本。当他再次尝试注册时不会丢失错误消息但会留下
class RegisterController {
public function DoControllNewUser() {
$Validation = new Validation();
$Stringer = "";
//..skapar
$RegisterView = New RegisterView();
$UserHandler = new UserHandler();
if ($RegisterView -> TriedTocreateNewUser()) {
if ($Validation -> ValidateUserName($RegisterView -> GetUserName()) == TRUE && ($Validation -> ValidatePassword($RegisterView -> GetPassword(), $RegisterView -> GetSecondPassword()) == TRUE)) {
$UserHandler -> DoCreateNewUser($RegisterView -> GetUserName(), $RegisterView -> GetPassword());
if($UserHandler -> DoCreateNewUser($RegisterView -> GetUserName(), $RegisterView -> GetPassword()) == false){
$Stringer .= "Användarnamnet finns redan hos oss!";
}
else{
# $RegisterView -> ChangeAction(true);
$Stringer .= $RegisterView -> NewMemberMessage();
}
}
if ($Validation -> ValidateUserName($RegisterView -> GetUserName()) == TRUE && ($Validation -> ValidatePassword($RegisterView -> GetPassword(), $RegisterView -> GetSecondPassword()) == false))
$Stringer .= $RegisterView->WrongSecondPasswordMessage();
return $Stringer;
}
$Stringer .= $Validation -> ShowErrorMessages();
return $Stringer;
}
}