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

153
Visualizações
How to prevent users from directly accessing my html website?

I've been messing around and trying to create an HTML website with a login page. Problem is, you can bypass the login page by typing (domain)/page.html, so I tried using this javascript script.

<script>
var x = document.referrer;    

if (x == "(domain)") {
    console.log(x);
} else {
    window.location.href = "/";
};
</script>

After adding that to my code, I ran into another problem. I go through the login page and hit submit. It redirects me to page.html like it should, but then it instantly redirects me back to the login page. Can someone help with this?

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

0

On client side one can easily mess with your code.You should study how to perform authentication on the server-side.

If in case you are using PHP as backend then in login.php file you should do it as follows

//after login verified
//You have to learn how to make a verification token
setcookie("remember",$ver_token,time()+45345345 ,"/",true,);
header("Location: http://www. (domain)/page.php/");

// some additional menipulation if you want

And in the page.php file you will get the cookie else redirect to the login.php file

// On the top of the login.php file 
if (isset($_COOKIE['remember'])) {
// Check in the database and do other stuff
}
else{
header("Location: http://www. (domain)/login.php/");
}

My suggestion is first learn some about backend programming and then try to do login because a hacker or attacker may easily view the page.html file because no verification on the server side. Client side can be manipulated very very easily.

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