I have a little problem, and I hope you can help me.
I’m looking to create pages that are accessible only to people who would have a password, but here’s the complexity:
When the person clicks on “access”, it arrives on a page where an inputbox is displayed. He needs to enter an access code. In reality, there are several, each code having to return to a different page. These codes would therefore be in a database and there must be a search in the database to give when the user validates the code.
example :
User A: enters the code XXXX and after validation, is returned to page /XXXXXX
User B : enters the code YYYYY and after validation, is returned to the page /YYYYYYY
Actually it was the next step (a sort of referal program)
Right now, I just need to send users to a specific page when they enter a specific word.
I’m selling subscriptions and offer coupons. When they click on “I have a coupon”, depending on the coupon, they should be redirect to one or another page.
They don’t need to be logged (but yes we have a login feature)
Hi,
You can simply get the correct path for each input (based on the way you have saved the data and defined your URLs) and use wixLocation.to . Use query to get the right path from the database and redirect the user. If you are having a hard time to figure it out please describe how the URL’s are defined.
Hi i am having the same issue please have a look at my code
import wixLocation from ‘wix-location’ ; import wixData from ‘wix-data’ ;
export function searchButton_click ( event ) {
//Runs a query on the “usernamesP2k” collection
wixData . query ( “UsernamesP2k” )
// Query the collection for any items whose “usercodesP2k” field contains // the value the user entered in the input element
. contains ( “UsercodesP2k” ,
$w ( “#searchBox” ). value )
. find () // Run the query
. then (( res ) => { let item = res . items ; if ( item . length > 0 ) { let URLP2k = item [ 0 ]. URLP2k ; //use your own field key instead of “link”
wixLocation . to ( URLP2k );
}
) }