When I was younger the first "password protected" pages I had were basically just pages not linked from the home page, that you needed to know the name of to navigate to. While this is obviously not secure enough for businesses, for many personal home pages that don't want complicated logins this works just fine. In this tutorial I will show you how to make such a login.
Time Required: 5 mins
<form action="go.php" method="post">This code puts a text box on your page that allows users to enter the page they want to be redirected to. If the user enters "cat.html" they will be taken to that file on your server. It will then send this information to go.php, which we will create next.
<INPUT type="text" name="page">
<input type="submit" value="Go">
<?phpThe above code goes in the file go.php. It simply takes the file you entered on the first page and redirects you to it. This is a very simple way of hiding a page. You need to remember however this is not a secure way of protecting files. Anyone can still navigate to your page, or in fact use your PHP script to redirect their own pages. This can be a nifty little script, but use it with caution.
$page = $_POST["page"];
header("Location: $page") ;
- While the code in step one can go anywhere you want, the code in step two cannot be anywhere but the very top of the go.php file.
- If you are worried about someone else using your PHP script, try checking the referrer before running the redirect.
What You Need
- A server that runs PHP
- A secret page you want your users to be redirected to
- People to share your secret with!