Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8903251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:49:21+00:00 2026-06-15T01:49:21+00:00

I’m trying to create a user registration form and create collection upon registration. I

  • 0

I’m trying to create a user registration form and create collection upon registration.
I tried following code, but when i try to execute i get this error:
HTTP 400 Bad Request and page cannot be displayed. Here is the code:

xquery version "1.0";

declare namespace request="http://exist-db.org/xquery/request";
declare namespace response="http://exist-db.org/xquery/response";
declare namespace xdb="http://exist-db.org/xquery/xmldb";
declare option exist:serialize "method=xhtml media-type=text/html indent=yes";
declare variable $database-uri as xs:string { "xmldb:exist:///db" };
declare variable $redirect-uri as xs:anyURI { xs:anyURI("login.xql") };

   declare function local:header() as node(){
<div style="background-color:#b0c4de; padding: 20px; border: 1px solid black;">
<h1>test</h1>
</div>
};

declare function local:footer() as node(){
<div style="background color:#eee; height: 1%; padding:20px; border: 1px solid black;">
<p>PROJECT</p>
</div>
};      

declare function local:reg($user as xs: string) as element()?
{
let $password := request:get-parameter("password", "")
let $password2 := request:get-parameter("password2", "")
return
    if (not(xdb:exists-user($user))) then ( 
    xdb:create-collection($database-uri, $user),
    xdb:create-user($user, $password, "guest", ()),
    response:redirect-to($redirect-uri)
    ) else
        <p>User already exists!</p>
};

declare function local:do-reg() as element()?
{
    let $user := request:get-parameter("user", ())
    return
        <p>{$user}</p>
        if($user) then
            local:reg($user)
            else ()
};

<html>
<head><title>Registration</title>

</head>
 <body>
 {local:header()}
  <h1>Forma for reg</h1>
  <form action="{request:get-uri()}">
  User Name: <br />
  <input type="text" name="user" size="20" />
  <br />
   Password: <br />
    <input type="password" name="password" size="20" />
  <br />
   Confirm: <br />
    <input type="password" name="password2" size="20" />
  <br />

  <input type="submit" />
  <input type="reset" name="reset" value="Clear" />
  </form>
  {local:do-reg()}
  {local:footer()}
  </body>
</html>

Please help, i’m beginner in xquery and exist db. Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:49:22+00:00Added an answer on June 15, 2026 at 1:49 am

    I got it, In exist you can’t register new user if you are not in db group of premissions.
    So what needs to be done is to create a new user for you collection, and give him right premissions, then you need to login with that user in order to register/create new user.

    xmldb:login('/db/yourcollection', $admin, $password)
                               .
                               .
                               .
                        your registration code
    

    the problem with this is that you put admin user and password in your .xql document – and that is not a good idea. But you can use:

    util:base64-encode

    and

    util:base64-decode
    

    to encode and decode you password. so how i did it is like this:

    system:as-user((util:base64-decode(“bXBhcmF2YWM=”)),(util:base64-decode(“cGFzcw==”)), (
    if (not(xdb:exists-user($user))) then (
    xdb:create-collection($database-uri, $user),
    xdb:create-user($user, $pass, ‘user’, ()),
    response:redirect-to($redirect-uri)
    ) else

    User exists!

    ) )

    Also there is another way to do this, even more secure, take a look at this example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I need to clean up various Word 'smart' characters in user input, including but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.