Jump to content

Load another page before that 1 loads


Sharkadder

Recommended Posts

ok in my website i have a passworded area, now as you know not all passworded areas are bullet proof but i have applied 2 ways of passwording the required page, 1 by typing a username in(which is easy to crack yes i know) and 1 where you have to know the name of the page you wish to open(which isnt so hard to crack as its not in the source code).now once somebody has typed in the username and proceeded and then the password they are granted permission in to the private area. The only problem is the user can save that page to there favourates and just click it and the page will come up.However i am wondering how i make it so that if the user has not logged in i.e just clicked that page in favourate or external link the page will redirect them to the login screen.Would you require to see my code for the 2 pages?So what i need is, if the user opens the "private area page" direct. instead of it just coming up because somebody could just get hold of the link, it will redirect them to the login page in which they will have to log in.i know i didnt explain it too well, but if you can help that would be great.Thanks

Link to comment
Share on other sites

I would definitly go for server side scripting as Webworldx said, but one option with javascript is "cookies".eg: document.cookie = 'logincookie=true;'when the user gives correct username/password create a cookie and check the value of cookie in the "secure" page. NOTE: If you do not set the expire time for the cookie in javascript then the cookie will expire when the browser is closed [this is what you need]even if the user bookmarks the page, when the page loads it must check for the cookie and must redirect to login page if cookie not set.Read this page for more info,http://www.quirksmode.org/js/cookies.html

Link to comment
Share on other sites

I would definitly go for server side scripting as Webworldx said, but one option with javascript is "cookies".eg: document.cookie = 'logincookie=true;'when the user gives correct username/password create a cookie and check the value of cookie in the "secure" page. NOTE: If you do not set the expire time for the cookie in javascript then the cookie will expire when the browser is closed [this is what you need]even if the user bookmarks the page, when the page loads it must check for the cookie and must redirect to login page if cookie not set.Read this page for more info,http://www.quirksmode.org/js/cookies.html
thanks pulpfiction, tomorrow i will send you some sample code of what the page looks like, then will you be able to midify my code so that it will ask for cookies? im relitevly new to java script so im still learning things
Link to comment
Share on other sites

Ok below is the BODY of my HTML file (the page where you type in the password NOT the username.<body><div id="hdr"><div style="font-weight:bold;font-size:12px;margin:6px 10px;"><span style="color:#FF0000; font-size:30px">Welcome To Sharkadder Software</a></span><span style="text-align:right;"><a href="contactus.html">contact us</a> |<a href="sitemap.html">site Map</a></span></div></span><img src="classic gaming.gif" alt="" border="0" width="450" height="40"/></div><div id="rh-col"><center><span style="color:#0000FF;font-weight:bold; font-size:15px">After the button below is clicked you will then be prompted for a password, type this in on the popup screen that appears.<align="center"></center><br><center><span style="color:#0000FF;font-weight:bold; font-size:15px">Please note you are required to press "submit password" not just press enter</center><center><script LANGUAGE="javascript"> <!--- Hide from tired old browsers var nifty_little_window = null; function gateKeeper() { nifty_little_window = window.open('gatekeep.html', 'theKeeper', 'width=350,height=200,resizable=1'); } // End hiding ---> </SCRIPT><form><input type="button" value="Click Here" onClick="gateKeeper()"</form></center></body></html>Ok now once that is run it allows the user onto the private are page, and the BODY of this pages code is shown below(this page is just HTML code)<body><div id="hdr"><div style="font-weight:bold;font-size:12px;margin:6px 10px;"><span style="color:#FF0000; font-size:30px">Welcome To Sharkadder Software</a></span><span style="text-align:right;"><a href="contactus.html">contact us</a> |<a href="sitemap.html">site Map</a></span></div></span><img src="classic gaming.gif" alt="" border="0" width="450" height="40"/></div><div id="rh-col"><center><span style="color:#FF0000;font-weight:bold; font-size:30px">Private File Download Area<align="center"></center></span></center><br><center><form action="upload_file.php" method="post"enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" id="file" /> <br /><input type="submit" name="submit" value="Submit" /></form></center><br><center><span style="color:#0000FF;font-weight:bold; font-size:15px">Please note, this area is strictly private & confidential for downloading files with administrator privliges</center><br><center><span style="color:#0000FF;font-weight:bold; font-size:15px">click a link to download the required file<align="center"></center><br><br><span style="color:#0000FF;font-weight:bold; font-size:20px">17th November 2006<align="center"></center><br><span style="color:#000000;font-weight:bold; font-size:15px"><a href="login.txt">login notes + Terms and conditions<align="center"></center><br><br><span style="color:#0000FF;font-weight:bold; font-size:20px">17th November 2006<align="center"></center><br><span style="color:#000000;font-weight:bold; font-size:15px">Object Position V1.0 Code<align="center"></center></body></html>Now can you please amend the code to allow cookies, i looked up on it and wasnt sure where the cookies bit of code was suppost to code, any help will be brilliant, cheers.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...