How to get a value from a database based on a value from the same row, but different column - pls help!!!!!!!!!!

I have updated my code to also use the new login way and it is now working in the editor. However, when I publish the site, it says I don’t have permission to access the page I want to go to.

This is my updated code:
import wixData from ‘wix-data’ ;
export async function checkUserExists ( email ){
if(typeof email !== ‘undefined’ && email !== “” ){
let options = {
“suppressAuth” : true ,
“suppressHooks” : true ,

    }; 
    //convert to lowercase and remove spaces 
    var  _email  =  email . toLowerCase (). split ( " " ). join ( "" ); 

    var  url  =  "" ; 
    **return**  wixData . query ( "Teachers" ) 
        . eq ( 'email' ,  _email ) 
        . find ( options ) 
        . then ( ( results ) =>{ 
            if  ( results.items.length  != 0 ) { 
                //returns the first row, if multiple rows with the same email are found 
                url  =  results.items [ 0 ]. phoneNumber ; 
                **return**  url ; 
            }  **else** { 
                **return**  "Error: User not setup. contact admin for help." ; 
            } 
        }) 
        . catch (( error ) =>{ 
            console . log ( "Error reading from table: Teachers.\n"  +  error.message ); 
            **return**  "Error: Fetch error trying to get data from table Teachers" ; 
        }); 
        } 
        **else** { 
            **return**  "Error: Email parameter passed in was invalid" 
        } 

}

Login page:
import { authentication } from ‘wix-members’
import wixLocation from ‘wix-location’ ;
import { checkUserExists } from ‘backend/login_functions’

let userEmail = “” ;

$w . onReady ( function (){

})

/**

  • Adds an event handler that runs when the element is clicked.
    Read more
  • @param {$w.MouseEvent} event
    */
    export async function loginTeacher_click ( event ) {
    // This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
    // Add your code for this event here:
    let email = $w ( “#emailLogin” ). value ;
    let password = $w ( “#passwordLogin” ). value ;
    userEmail = email . toLowerCase (). split ( " " ). join ( “” );
    console . log ( userEmail );
    authentication . login ( email , password )
console . log ( "Logging in" ); 
let  newLink  =  **await**  checkUserExists ( userEmail ); 
console . log ( newLink ); 
if ( newLink . substring ( 0,5 ) !==  "Error" ){ 
    let  realLink  =  "/teachers/profile/"  +  newLink ; 
    console . log ( realLink ); 
    wixLocation . to ( realLink ); 
} **else** { 
    console . log ( "Error occurred: \n"  +  newLink ); 
} 


    //console.log() 

}

This is the page that appears when on the published site

I have set the page settings so that everyone can view it, but it still gives me this page