It depends on if your webpages will be located on a Unix (Linux) server or a Windows 2000 (IIS server).
If its on a IIS server, then a code as simple as this will do on the top of the page u want protected
<%If session("user") = "" Then response.redirect("login.asp")%>
A good example of this way is if you try to click goto http://sharpnetwork.net/?download you get redirected to login.asp if you aren't logged in.
To get the Session("user") variable set, you create a form
<%If request("password") = "mypassword" Then
Session("user") = "hello"
Response.redirect("secretpage.asp")
End If%>
If you're using a Linux server, then you can add a file called .htaccess (google .htaccess for more info and how to) to the directory with the protected page in it. When someone goes to that page, it popup that box (Basic Auth box) that you may have seen on some sites.
If all of these are complicated, then the easiest way is to stick a java script on it. You can make it as simple as to popup a javabox and ask a password. The problem with that, is that all the person has to do is right click the page and View Source and can see the password (because java is client side, whereas .asp is server side). But I think I have seen some java tricks to where you can use some fancy encoding in the script to where you can't see the password in the source code. I would try to google java password protect for those examples.
2006-12-31 09:10:59
·
answer #1
·
answered by SharpGuy 6
·
0⤊
0⤋
Not an easy one, do i got 10 points for best answer?>
HU?
I thought I heard a yes :-)
Ok,its not an HTML code, you need to do the following, it works great! I am assuming you know how to ftp into your site....
Here ya go for my 10 points:
Instead of step by step, I decided to create for you a script, just change the username and password in it..... I will tell you how....
ENDS ABOVE .....
This script should only take you a few minutes to setup. The only thing you need to do is edit the username, password, and the page the person will direct to when the correct password is entered correctly.
First, copy the code in the above box and paste it into an HTML web page. The page could be named whatever you'd like: index.html for example.
Look for a line in the script that reads...
if (form.id.value=="userID") {
This is the username. Change "userID" it to whatever username you'd like to use.
Now look for a line in the script that reads...
if (form.pass.value=="password") {
Change "password" to the one you'd like to use.
Now look for a line that says...
location="page2.html"
This is the URL of the page that the person will be directed to when they enter the correct password. Keep in mind this assume that the page is located in the same directory of the page the password script is on. You may have to edit the path accordingly. If you're not sure, just put the complete URL of the page here. Example: http://www.yourdomain.com/file.html
The next step is optional. This is only if you want to alter the error messages that are displayed when the username or password is not entered correctly. If you don't change anything in these lines, the default error messages will display.
Look for a line that says...
alert("Invalid Password")
You can change "Invalid Password" to whatever message you'd like. For example, you can make it say, "The password you entered is incorrect. Please try again."
You can also do the same to the user Invalid ID section. Look for the line...
} else { alert("Invalid UserID")
Change "Invalid UserID" to whatever message you'd like to display when the username is incorrect.
Congratulations! You have just password protected a web page.
Kosher1
2006-12-31 09:04:02
·
answer #3
·
answered by Kosher1 2
·
2⤊
0⤋