Email as passcode - compared to user input?

Hello all!

I’m looking to create a passcode protected page, but I would like people to access it by entering their email address that they had previously entered on a form - if it’s an email address that was not entered into the form, it will not let them in.

Any ideas?

Thanks!

Hi,

I assume your form is submitted to a database collection holding all email addresses.
If so, use ’ wixData.query() ’ to check if the email exists when clicking a button (set a button onclick() )

Thank you! I’m very new to coding - where would each of these functions go? Is one embedded in the other?

Hi,

Yes… you should set onClick for your button that will look a bit like this:

export function button1_click() {
    const input = $w('textInput1').value;
    wixData.query('collectionName').eq('email', input).find().
        then(result => {
            //do something here...
        });
}

Liran.

Thank you!

Everything worked perfectly when I did this through preview - however once the page was published, nothing happens. Any reason that could be happening?

Hi,

Make sure to check your collection permissions and collection sync to live
Check out this checklist for further information.