473,700 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I password protect a page?

Hi there,

I don't know much about web design but I proudly managed to password protect
a page on my site. Later I realized that everyone looking at the source in
any web browser can see the password. Is there a way to improve this code so
that instead of the password people viewing the page source would only see
bullets instead of the characters of the password (or hide it alltogether?)

Thank you for your help.

Hi there

Here is the code:

<script language="javas cript">
<!--//

function pasuser(form) {
if (form.pass.valu e=="michael2") {
location="index 2.html"
} else {
alert("Invalid Password")
}
}
//-->
</script>

<tr><td><h1><i> <b>Password:</b></i></h1></td><td><form name="login"><i nput
name="pass"
type="password" ></td></tr>
<tr><td><inpu t type="button" value="Login"
onClick="pasuse r(this.form)"></td><td><br>
Nov 5 '05 #1
3 3326
This is not something you normally do in Javascript. There are a number of ways to do this. I assume you don't have access to the
actual webserver, if you do then you can setup authentication there. Otherwise you need to go to a dynamic content language like JSP
or PHP or something like that.

Dennis

Narlen wrote:
Hi there,

I don't know much about web design but I proudly managed to password protect
a page on my site. Later I realized that everyone looking at the source in
any web browser can see the password. Is there a way to improve this code so
that instead of the password people viewing the page source would only see
bullets instead of the characters of the password (or hide it alltogether?)

Thank you for your help.

Hi there

Here is the code:

<script language="javas cript">
<!--//

function pasuser(form) {
if (form.pass.valu e=="michael2") {
location="index 2.html"
} else {
alert("Invalid Password")
}
}
//-->
</script>

<tr><td><h1><i> <b>Password:</b></i></h1></td><td><form name="login"><i nput
name="pass"
type="password" ></td></tr>
<tr><td><inpu t type="button" value="Login"
onClick="pasuse r(this.form)"></td><td><br>

Nov 5 '05 #2

Narlen wrote:
Hi there,

I don't know much about web design but I proudly managed to password protect
a page on my site. Later I realized that everyone looking at the source in
any web browser can see the password. Is there a way to improve this code so
that instead of the password people viewing the page source would only see
bullets instead of the characters of the password (or hide it alltogether?)


This should be done on the server using htProtect(unles s you are on a
Microsoft server using Frontpage and perhaps some other Microsoft
programs.). If your host does not allow basic server side operations
such as this, dump your host and get another one. Good hosts that cater
to small business often are no more, or less, expensive than hosts that
cater mainly to casual users. There is a glut of hosts around the
world, and these days it makes little difference if your host is in
your own country or half-way around the world.

My domain host lets you select a shared Microsoft or Unix(Apache)
server. I use Unix. The control panel has nearly everything you might
want to use such as htProtect, php, perl, shopping carts, secure pages,
and automated domain search and purchase. Here is what my host says to
do to password protect:

"htProtect utility allows you to password-protect any directory on your
site so only authorized visitors can open its content with their
browsers.
To start htProtect, click the WebProtect icon on your home page.

Warning: Don't use this feature if you have Frontpage Extensions
installed. You would need to use Frontpage itself to perform this
function."

It only takes a few very simple inputs to a form and a few key clicks
to password protect any directory you wish. There is really no need to
have to bother to write your own php or other script to password
protect.

Nov 5 '05 #3
wl
"Narlen" <m_******@hotma il.com> wrote in message
news:BF914485.1 5680%m_******@h otmail.com...
Hi there,

I don't know much about web design but I proudly managed to password
protect
a page on my site. Later I realized that everyone looking at the source in
any web browser can see the password. Is there a way to improve this code
so
that instead of the password people viewing the page source would only see
bullets instead of the characters of the password (or hide it
alltogether?)

Thank you for your help.

Hi there

Indeed the best way to do password protection is serverside. If this is
impossible, please visit Real Gagnon's site:

http://64.18.163.122/rgagnon/jsdetails/js-0022.html

Wim
Nov 5 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3414
by: Wm | last post by:
Something just occurred to me... <yeah, I know, it scared me too> I just password-protected a website by including a password authentication script in each page of a private section. The script checks the login against the mySQL database. This type of protection will only affect the .php pages, won't it? The images that are contained in the pages are not protected, as they would be if I had a .htaccess file on the parent directory..? This...
7
2146
by: juglesh | last post by:
<body><div align="center"> <?php if (!isset($password)){ ?><form action="<?php $_SERVER; ?>" method="post"> type password here&nbsp;<input name="password" type="text" size="8"> then <input name="submit" type="submit"> </form> <?php die; }
10
2698
by: Mike Painter | last post by:
I need a scheme to give people password access to JavaScript quizzes that I have. I've done a lot of programming but almost no JS. Probably one password per person for each of five tests. I suspect I will be maintaining the lists but if there is a *very* easy routine that an end user could use it would be nice. It usually takes more than five visits to get this guy up on anything new.
10
6009
by: Max | last post by:
Hello all, I am trying to protect a page within my site with a JS password scheme. Now I know JS can be quite easily "circumvented", but I came by a code below. My question is: 1. Is there a way to find a password for this script? How easily? 2. Is there a stronger scheme available in JS?
0
1140
by: teenzbutler | last post by:
I am attempting to password protect some web pages. I have following the instructions within the following article: Microsoft Knowledge Base Article - 301464 - How To Use Simple ASP Code to Password Protect Your ASP Pages. Every thing works fine. The am having a problem figuring out how to add additional usernames and passwords. It appears as though the code is only good for one user. Can anyone help me out. I have pasted the code below....
5
2993
by: Brent Burkart | last post by:
I want to protect my website with a user and password. I have SQL Server 2000 where I want to store the users and passwords and the website is complete. I just need to add in some security with password protection. Can anyone help me out?
4
2568
by: sunniyeow | last post by:
Hi, My question is regarding password protecting 2 different folders inside a single virtual directory using forms authentication method. Easier if I illustrate things out... - <authentication mode="Forms"> - Virtual Directory aka Top Level Root = /mysite - Inside /mysite I have 2 sub-folders which I want to password protect = /adminonly and /memberonly - /adminonly is assigned to a single Admin user with a hard-coded pair of username...
5
2800
by: nick | last post by:
I need to create a simple asp.net application that use password protect some html pages. The html page provider doesn't know asp.net. And the host doesn't allow me to create user accounts. What's the best way to store users/password except database tables? and to store html files?
22
5807
by: teejayem | last post by:
Hi, I am new to programming with databases and was wanting some help. Is there any way to password protect an access database and access sent sql commands to it via vb.net code? Any help would be much appreciated. Thanks in advanced.
0
8645
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6561
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5903
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4404
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4657
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2392
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.