-
Notifications
You must be signed in to change notification settings - Fork 12
Check if record exists in the database on insert
Using the server-side data validation you can check if a record already exists in the database. This is useful when creating users so you can check if the email is already registered and if yes, you can show an error message and don't allow insert.
Select your Insert Record action(1) and right click the step before the insert record step(2):
Select Validator:
And then Add Validate Data:
Select validate data step and click validate options:
Click the add new button:
Double click the expression field so that the dynamic data picker appears. Click the dynamic data picker:
And select the POST variable (form input) which value you want to validate. In our case this is the email input:
Then add new validation rule for the selected expression:
Open the Database category:
And select Does not exist in database:
Select your database connection:
Select the database table you insert your data into:
And select the database table column to check for existing record:
Customize the error message that will appear if a record exists:
In the linked field enter the name of the form field, which is on your page. If you don't do this the error message won't appear on the page:
Click Save:
Then save your server action and you are done. The insert won't run if the record already exists in the database.
© Wappler 2018
- Home
- Getting Started
- How-to Guides
- Project Manager
- Bootstrap 4 Visual Designer
- Image Galleries & Animations
-
Server-side Components
- Connecting to a Database
- Creating Database Queries
- Binding Data on the Page
- Formatting Dynamic Data
- Filter Data with Text Input
- Filter Data with URL Param
- Dynamic Select Menu
- Dynamic Sortable Table
- Dynamic Paging
- Server Side Includes (SSI)
- Insert Database Record
- Get Inserted Record ID
- Delete Database Record
- JSON Data Sources
- Send Form to Email
- Debugging Problems
- Security & Login
- Form & Data Validation
- Notifications & Alerts
- Mobile Apps