Best practice to do this

I have a form that I want to check in an old database if this exists. Of which I can get working.
But I want to be able to goto page1 if the record is there and goto page2 if it is not there.
What is the best way to do this, I’ve not quite got my head around the condition in action steps yet.

Hi Peter,

When would you like to go to page 1 or 2? Is it when the user submits the form?

I want the user to enter their name and if it is there in the old database then I would like it to goto page 1.
However if it is not there in the old database I need it to goto page 2

Basically I need to make sure they are in the old DB before they proceed to update their details
In dreamweaver it used to be ‘if no record returned’

You can do the following in your server action:

  • Add a database query and filter it by the (user)name.
  • Condition step - use the query as an expression
  • THEN > setvalue, let’s give it a name userexists and add a value of 1
  • ELSE > setvalue, we give it the same name userexists and add a value of 0

enable output for both setvalue steps.

On the front end, add the browser component, then for the server action add dynamic event -> success add browser go to.
Here you just need a condition if the value of the setvalue step is 1, got to page 1, else go to page 2:

dmx-on:success="browser1.goto(serverconnect1.data.userexists == 1 ? 'page1.html' : 'page2.html')"

So the logic here is: first you check on the server side if the query returns results, then you send the result to the front end, where you use it in a condition (if record exists/does not exist).

1 Like

Awesome cheers buddy, I learn something new every day :wink:

1 Like