sub Check_dummypassword_username ()
{
   my $bUserExists;

   &AddError("username", i18n("No username, please enter!!"))
       if(!&GetField("username"));

   $bUserExists = $oDbSessionGL->SqlSelect
       ("SELECT 1
         FROM wwwdb_state
         WHERE
            key_name  =    'login' and
            key_value LIKE ?",
        &GetField("username") . "%%")->[0]->[0];

   &AddError("username",
             i18n("Sorry, that username already exists, please re-enter!!"))
       if ($bUserExists);

}

sub Check_dummypassword_password1 ()
{
   if(&GetField("password1") ne &GetField("password2"))
   {
      &AddError("password1",
                i18n("Difference in passwords, please re-enter!!"));
      &SetField("password1", "");
      &SetField("password2", "");
   }
}



sub MyBtnNew()
{

   if(!&GetAttr("RecordOk"))
   {
      &GenPage();
   }
   else
   {
      my $cSessionId;
      my $oSession;
      my $cUsername;

      my %hDefaults = ();

      $oSession = Session->new(&GetAttr("DbHandle"),
                               "Id"       => "NEW",
                               "IdLength" => 16) or
         die i18n("Could not get the session-id!");
      $cSessionId = $oSession->getId();

      $cUsername = &GetField("username");

      $hDefaults{"login"} = ($cUsername . "," .
                             crypt(&GetField("password1"), "WW"));
      $hDefaults{"IsAdmin"} = &GetField("isAdmin");
      $hDefaults{"[WWWdb] Lang"} = &GetField("lang");

      foreach (keys %hDefaults)
      {
         $oDbSessionGL->SqlDo
             ("INSERT INTO wwwdb_state
                 (session_id, key_name, key_value)
               VALUES
                 (?, ?, ?)",
              $cSessionId,
              $_,
              $hDefaults{$_});
      }

      &SetField("username",  "");
      &SetField("password1", "");
      &SetField("password2", "");
      &SetField("isAdmin",   "");
      &SetField("lang",      "");

      &OkForm("Information",
              sprintf(i18n("WWWdb-User '%s' created"),
                      $cUsername));


   }
}

1;

