Restrict access to a web page
Hi
I have a web page that I would like to restrict access to.
I have some code that presents the user with a small window into which they must type a password, this is generated using javascript.
However the window opens up in the top left hand corner of the screen and not in the centre. I would like it to appear in the centre and would be gratefull for ay advice.
Here is my code:
<html>
<head>
<title>Password test</title>
<script language="JavaScript">
var password;
var pass1="password";
password=prompt('Please enter password?',' ');
if (password==pass1) alert('That Is Correct!');
else {
window.location="my_link";
}
</script>
</head>
</html>
Thanks for any responses
GB
Michael James Swan posted this at 10:10 — 16th August 2008.
He has: 400 posts
Joined: May 2008
I recommend using .htaccess and .htpasswd to prevent access to a page or directory.
If you google .htaccess creator or take a look on your website hosting control panel then i am sure that you may find something there which may help.
Best Regards,
Mike
webwiz posted this at 21:50 — 16th August 2008.
He has: 629 posts
Joined: May 2007
I agree with Mike. Anyone who knows about their browser's "view source" option can read your HTML, locate the script, and read the password.
Michael James Swan posted this at 22:42 — 16th August 2008.
He has: 400 posts
Joined: May 2008
Thank you webwiz,
Yes, there are many different ways to making a file or directory password protected.
I have found that with .htaccess and .htpasswd , that you can also make multiple username and password combinations.
I have used this for one of my sites, so that if i cannot remember one of the passwords or usernames, then i can use one of the others, Since i have so many; i found this a great way to make sure i have access.
If you really are looking at using the above code, then please take care and find an encyption program which you can use to encrypt the code.
Best Regards,
Mike
greenockboy posted this at 15:07 — 17th August 2008.
They have: 6 posts
Joined: Jul 2008
Thanks for the replies people.
I will certainly take a look at the suggestions, I suppose then that there isn't a way to centralise the window after all.
Regards
GB
Michael James Swan posted this at 18:09 — 17th August 2008.
He has: 400 posts
Joined: May 2008
If you use .htaccess and .htpasswd the window is almost always central.
archer_fire posted this at 07:18 — 2nd May 2009.
They have: 1 posts
Joined: May 2009
Hello there,
Can you explain how does the above files work.
Can I use them if I am using ASP with VBScript.
Thanks
Archer
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.