Form to check if a query returns a record

Hi,

I have a form and user enters their code and I am trying to connect it to a Server action which runs a query based on the code they entered, if the query returns a result (I used ‘count’ here, there will always be 1 or nil counts), then they can be redirect to a specific page, otherwise an error message shoulder appear.

I have tried several ways without much success. It’s not the same as check if record exists in a database (https://docs.wappler.io/t/check-if-a-database-record-already-exists-before-inserting-a-new-entry/2847)!

Here is what I have so far… also the redirect doesn’t work.
Any suggestions would be helpful. Thank you.

Here is my server actions:

Community Page
Last updated: