How to create a registration form and check for existing usernames
I'm trying to create a "simple" register script. I've created 4 fields:
So user enters a preferred username into the UnameCheck field.
Script aims to search the username field against what the user just entered into UnameCheck field to see if that username is already in use.
If found, show custom dialog box to prompt user to enter a different username.
Else set username to UnameCheck
Here's what I've done so far. It's not doing what I intend to do. I know the issue is with comparing two fields and I'm pretty sure I'm not doing it right. So please help:
Show Custom Dialog ["Register"; "Please provide a username and password" TableName:UnameCheck; TableName;SetPassword"
Perform Script ["UsernameCheck"]
Set Error Capture [On]
Find Matching Records [Constrain; TableName:username]
If [Get (LastError) = 401]
Set Field [TableName::username; TableName:UnameCheck]
Show Customer Dialog ["Username in use"; "If you have already registered, please use the login link. Otherwise please pick a different username"]