Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect to index,htm

Status
Not open for further replies.

chokdii

IS-IT--Management
Aug 31, 2005
3
CA
Hi, I am looking for a simple script that will force users that didn't come from my password protected page to be redirected there. I have tried a few different scripts now, but none of them seem to be working for me. I know almost nothing about javascript, so I can't really significantly re-write any of the scripts I have tried.

Basically I just want something that will check where the surfer came from, and it is wasn't my index.htm page, send them there.

Any help would be greatly appreaciated :) thanks
 
If the user has javascript off it won't work your way.

The best advice is to do this server-side. Even then, the REFERRER is optional and some browser configurations don't pass this information on.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Thanks Jeff,

DO you have any suggestions on something simpler. I could just put the password box on that actual page and then rename that page as the index, but for some reason the page keeps appearing along with my password box when I have tried to do this. Can you recommend any good but simple scripts for putting a password on a page?

Thanks :)

 
You could put this code on the index.htm page as your login code:
Code:
<form action="" method="get" onsubmit="this.action=this.elements['password'].value+'.html';">
<input name="password">
<input type="submit" value="Proceed">
</form>
And make the password the name you give the file they navigate to. For example if the password was chamber then the above code would redirect the user to chamber.html. You could have multiple passwords taking you to different "landing pages" if you wanted... and each landing page could have a meta-refresh redirecting to the one common "logged in" page.

Now, the code above is not rocket science... but there is no way to achieve security using javascript and it provides a pretty safe way to hide your page(s). It does require javascript - without javascript the user will not be able to proceed.

Let us know how you go!
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top