mike1023
Account Closed
- Impact
- 3
Hi,
I thought I would post a simple method to password protect an area on your website and include the files needed.
This can easily be done client side using JavaScript, however be aware that this should not be used for transactions and areas that should be forbidden in a heavy manner. The best use of this script is for a generic area that should be protected.
You can copy and paste the form anywhere you want in your page to provide the "user" and "pass" form. Edit the script where it is noted and change the URLs for the redirect pages.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Thats it! Enjoy!
I thought I would post a simple method to password protect an area on your website and include the files needed.
This can easily be done client side using JavaScript, however be aware that this should not be used for transactions and areas that should be forbidden in a heavy manner. The best use of this script is for a generic area that should be protected.
You can copy and paste the form anywhere you want in your page to provide the "user" and "pass" form. Edit the script where it is noted and change the URLs for the redirect pages.
--------------------------------------------------------------------------
Code:
<form>
<p><span class="formtextstyle">Enter User Name: </span><span class="formaccent">*</span>
<input name="text2" type="text" class="formstyle" value="Login" size="20" maxlength="10">
<span class="formtextstyle">Enter Password:</span>
<span class="formaccent">*</span>
<input name="text1" type="password" class="formstyle" value="password" size="20" maxlength="10">
<input name="Submit" type="button" class="formstyle" onclick=javascript:validate(text2.value,"user",text1.value,"pass") value="Go >>" >
<!-- changing the words "user" and "pass" above will modify the user name and password for login.-->
</p>
</form>
<script language="javascript">
function validate(text1,text2,text3,text4)
{
if (text1==text2 && text3==text4)
load('success.html'); <!--This is your page that the user is taken to when they have entered the correct login information. You can change it to whatever you want.-->
else
{
load('failure.html'); <!--This is the page the user is taken to when they have entered the incorrect login information. You can change it to whatever you want.-->
}
}
function load(url)
{
location.href=url;
}
</script>
Thats it! Enjoy!
Last edited by a moderator:












