Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
How can I redirect to login page after registration in this code

every help me :(((. here is link to my code https://github.com/tranluongtiensi/registration_system

I want to redirect the user to login page after registration, I have tried many ways but it doesn't work. thank everyone very much

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can just use the window.location.href when you submit your signup form. So your code for registerUser(...) would look something like this.

async function registerUser(event){
      event.preventDefault()
      const username = document.getElementById('user').value
      const password = document.getElementById('password').value
      const password_confirmation = document.getElementById('password_confirmation').value
      const phone = document.getElementById('tel').value

      const result = await fetch('/register',{
         method: 'POST',
         headers: {
           'Content-Type': 'application/json'
         },
         body: JSON.stringify({
           username,
           password,
           password_confirmation,
           phone
         })
      }).then((res) => res.json())

      if (result.status === 'ok') {
         alert('success');
         // on a successful signup, redirect user to the login page
         window.location.href = 'LINK_TO_SIGNIN_PAGE'; // exp. http://localhost/signin.html
      }else {
        alert (result.error)
      }
    }

Give it a go!

about 4 years ago · Juan Pablo Isaza Relatório

0

You need to add a redirect here to this line here

for example :

window.location.href = 'login.html'
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda