| | |||||
| ||||||||
| CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Account Closed Join Date: Jul 2007
Posts: 349
![]() ![]() ![]() | Simple Complete Script To Password Protect An Area On Your Site 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. ????: NamePros.com http://www.namepros.com/code/382647-simple-complete-script-password-protect-area.html 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 SecondVersion; 10-08-2007 at 07:57 PM.
|
| |
| | #3 (permalink) |
| Traveller Join Date: Mar 2007 Location: Yet another city
Posts: 1,419
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Anyone considering using this should be warned that it can be bypassed by anyone who knows how to view the html source of a page.
__________________ NameCooler.com |
| |
| | THREAD STARTER #4 (permalink) |
| Account Closed Join Date: Jul 2007
Posts: 349
![]() ![]() ![]() | right on i agree! Maybe i didn't make my warning clear enough on it :-| Everyone please know that this is ALL client side so anyone with knowledge of pretty much anything development related could look at the source and see the code to enter the access area. I would only use it for friendly sites that are not needed to be protected in a "unaccessible" way. Otherwise use a server side script PHP or something similar. |
| |
| | #5 (permalink) |
| Danltn.com Join Date: May 2007 Location: Danltn.com / Nottingham, UK
Posts: 1,201
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Here's a half-assed attempt by me. You'd need to check on the page it goes to that the details are correct. PHP Code:
__________________ |
| |