Password protected page

I’m planning to create a “gaming” website as part of our team building activity online…

I want each members to access different pages using their own employee ID number. So it looks like this…

Front page: there’s a button to click and they will be prompted to enter password (which is their employee number) and when that specific employee number is recognized, they will be routed to another page where the game begins.

So if Employee A enters employee ID number of 123456, she will be routed to GAME A page in the website.
Employee B enters employee ID number of 678901, she will be routed to GAME B page in the website… and so on.

Can we achieve this using Corvid? Thank you!!

Hey,

You could set this up using Corvid.

To do it you would have to create separate statements for each employee number so if there are a lot of employees it could be a lot of code and a lot of pages.

Use the to() function from the wix-location API to redirect the site visitors after entering their employee numbers.

Something like this:

import wixLocation from 'wix-location';

$w.onReady(function () {

});

export function button1_click(event) {
 if ($w("#input1").value = (12345).toString())
   wixLocation.to("/page-name")
if ($w("#input1").value = (67890).toString())
   wixLocation.to("/other-page-name")
}

Hope this helps!

Dara | Corvid Team

Hey Dara! Thank you so much :smiley:

Hey Dara, sorry but I’m having trouble when I edited the code and placed it on my site… error message:

so what I did is:

export function button1_click ( event ) {
if ( $w ( “#input1” ). value = (123456). toString ())
wixLocation . to ( “/123456” )

123456 in value is the employee number
123456 in location is the page name

another question though, the code says "button1_click(event) so meaning do I have to add like a submit button on the page and not just user input? LOL sorry…

so if I’ll be adding a submit button, I need to connect the user input and the button to a dataset?

THANK YOU SO MUCHHH!!!

You should replace both = signs, with ===
If you see that error message, it would seem you already have added a button that starts this code on click?

Otherwise, these are the steps:
You should place a button on your page, with the ID #button1
You can set this by right mouse on the button > View Properties
(If it’s the first button on your site, it will be already #button1)
In the same properties panel you should also click the + sign next to onClick to add a hook.
Now your function is connected to the button. There is no dataset involved.

But the Codes what you write in Code other can see in html code google or other platforms? And it is possible that when the input wrong, than box show up “wrong password” somthing like this? And not only numbers? Thanks ^^