Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda