Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!