Scripting problem

A

Anthony

Can someone tell me why this script isn't working? I get an error on
page message. Thanks.

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>New Page 1</title>
<script language="javascript">
<!-- Begin

var userData = new Array()
userData[] = new Array("sbazell", "0513", "Agent Bonus/aknram.htm");
userData[] = new Array("techambers", "Chambers1", "Agent
Bonus/xplojh.htm");
userData[] = new Array("afrye", "AJPMF1998", "Agent Bonus/yxjgrv.htm");
userData[] = new Array("thead", "Blessed07", "Agent Bonus/jnsihy.htm");
userData[] = new Array("cryjohnson", "kittycat6", "Agent
Bonus/xdowud.htm");
userData[] = new Array("rckenley", "Baller", "Agent Bonus/vxjuye.htm");
userData[] = new Array("nmock", "Dimonds4ever", "Agent
Bonus/zzojkl.htm");
userData[] = new Array("gnimley", "Qwejue", "Agent Bonus/hsoywm.htm");
userData[] = new Array("vestewart", "TD3301", "Agent
Bonus/muedjk.htm");
userData[] = new Array("jthrelfall", "jeff1", "Agent
Bonus/uehdlo.htm");

function Login() {
var username=document.login.username.value.toLowerCase();
var username=document.login.password.value.toLowerCase();

for (i=0; i<userData.length; i++) {
if (username==userData [0] && password==userData [1]) {
window.open(userData [2]);
return true;
}
}
alert("Invalid Login!");
}
// End -->
</script>
<meta name="Microsoft Theme" content="boldstri 1011, default">
<meta name="Microsoft Border" content="t, default">
</head>

<body>
<center>
<form name=login>
<table width=225 border=1 cellpadding=3>
<tr><td colspan=2><center><font size="+2"><b>Bombers Only
Area!</b></font></center></td></tr>
<tr><td>Username:</td><td><input type=text name=username></td></tr>
<tr><td>Password:</td><td><input type=password name=password
size="20"></td></tr>
<tr><td colspan=2 align=center><input type=button value="Show Me The
Money!" onClick="Login()"></td></tr>
</table>
</form>
</center>

</body>

</html>
 
M

McKirahan

Anthony said:
Can someone tell me why this script isn't working? I get an error on
page message. Thanks.

"... isn't working" -- could you be more specific?

Also, strip it down to the bare minimum that still causes the problem.
 
M

McKirahan

McKirahan said:
"... isn't working" -- could you be more specific?

Also, strip it down to the bare minimum that still causes the problem.

1) You declared "var username" twice but didn't declare "var password".

2) You didn't assign an index to userData[] items.

Try the following script instead:

<script type=""text/javascript">
var userData = new Array()
userData[0] = new Array("sbazell", "0513", "Agent Bonus/aknram.htm");
userData[1] = new Array("techambers", "Chambers1", "Agent
Bonus/xplojh.htm");
userData[2] = new Array("afrye", "AJPMF1998", "Agent Bonus/yxjgrv.htm");
userData[3] = new Array("thead", "Blessed07", "Agent Bonus/jnsihy.htm");
userData[4] = new Array("cryjohnson", "kittycat6", "Agent
Bonus/xdowud.htm");
userData[5] = new Array("rckenley", "Baller", "Agent Bonus/vxjuye.htm");
userData[6] = new Array("nmock", "Dimonds4ever", "Agent
Bonus/zzojkl.htm");
userData[7] = new Array("gnimley", "Qwejue", "Agent Bonus/hsoywm.htm");
userData[8] = new Array("vestewart", "TD3301", "Agent
Bonus/muedjk.htm");
userData[9] = new Array("jthrelfall", "jeff1", "Agent
Bonus/uehdlo.htm");
function Login() {
var username=document.login.username.value.toLowerCase();
var password=document.login.password.value.toLowerCase();
for (i=0; i<userData.length; i++) {
if (username==userData [0] && password==userData [1]) {
window.open(userData [2]);
return true;
}
}
alert("Invalid Login!");
}
</script>
 
A

Anthony

Thanks for the suggestion. I made the changes that you suggested and
unfortunately it did not work. I received the following error message
when I attempted to preview in FP:
An error has occurred in the script on this page.
line: 33
char: 34
Error: expected ' ; '
Code:0

When I attempted to preview in the browser (IE 6.0), nothing happened
except that on the bottom left of the page, I received a brief "error
on page" message and then the "done" message. I appreciate the help.
Is there anything else that you need from me to try to assist me
further? Thanks.
McKirahan said:
"... isn't working" -- could you be more specific?

Also, strip it down to the bare minimum that still causes the problem.

1) You declared "var username" twice but didn't declare "var password".

2) You didn't assign an index to userData[] items.

Try the following script instead:

<script type=""text/javascript">
var userData = new Array()
userData[0] = new Array("sbazell", "0513", "Agent Bonus/aknram.htm");
userData[1] = new Array("techambers", "Chambers1", "Agent
Bonus/xplojh.htm");
userData[2] = new Array("afrye", "AJPMF1998", "Agent Bonus/yxjgrv.htm");
userData[3] = new Array("thead", "Blessed07", "Agent Bonus/jnsihy.htm");
userData[4] = new Array("cryjohnson", "kittycat6", "Agent
Bonus/xdowud.htm");
userData[5] = new Array("rckenley", "Baller", "Agent Bonus/vxjuye.htm");
userData[6] = new Array("nmock", "Dimonds4ever", "Agent
Bonus/zzojkl.htm");
userData[7] = new Array("gnimley", "Qwejue", "Agent Bonus/hsoywm.htm");
userData[8] = new Array("vestewart", "TD3301", "Agent
Bonus/muedjk.htm");
userData[9] = new Array("jthrelfall", "jeff1", "Agent
Bonus/uehdlo.htm");
function Login() {
var username=document.login.username.value.toLowerCase();
var password=document.login.password.value.toLowerCase();
for (i=0; i<userData.length; i++) {
if (username==userData [0] && password==userData [1]) {
window.open(userData [2]);
return true;
}
}
alert("Invalid Login!");
}
</script>
 
L

Lee

Anthony said:
Thanks for the suggestion. I made the changes that you suggested and
unfortunately it did not work. I received the following error message
when I attempted to preview in FP:
An error has occurred in the script on this page.
line: 33
char: 34
Error: expected ' ; '
Code:0

When I attempted to preview in the browser (IE 6.0), nothing happened
except that on the bottom left of the page, I received a brief "error
on page" message and then the "done" message. I appreciate the help.
Is there anything else that you need from me to try to assist me
further?

The code he posted works without errors.

You either copied it incorrectly or your error is elsewhere.
Create the simplest page you can make that shows the error.
It shouldn't be more than about 40 lines of code.

If you don't find the error while doing that, post the entire
simplified page so we can test your exact code.


--
 
A

Anthony

I copied the script directly from his usenet posting. The only
modification that I made was to the second " in the <script
type=""text/javascript">> tag. This works for users sbazell,
cryjohnson, jthrelfall but gives the Invalid Login alert for everyone
else. I am not recieving the error message however when I preview in
FP. Could something else be wrong? Here is the script from my page:

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Login Page</title>
<meta name="Microsoft Theme" content="boldstri 1011, default">
<meta name="Microsoft Border" content="t, default">

<script type="text/javascript">

var userData = new Array()
userData[0] = new Array("sbazell", "0513", "Agent
Bonus/aknram.htm");
userData[1] = new Array("techambers", "Chambers1", "Agent
Bonus/xplojh.htm");
userData[2] = new Array("afrye", "AJPMF1998", "Agent
Bonus/yxjgrv.htm");
userData[3] = new Array("thead", "Blessed07", "Agent
Bonus/jnsihy.htm");
userData[4] = new Array("cryjohnson", "kittycat6", "Agent
Bonus/xdowud.htm");
userData[5] = new Array("rckenley", "Baller", "Agent
Bonus/vxjuye.htm");
userData[6] = new Array("nmock", "Dimonds4ever", "Agent
Bonus/zzojkl.htm");
userData[7] = new Array("gnimley", "Qwejue", "Agent
Bonus/hsoywm.htm");
userData[8] = new Array("vestewart", "TD3301", "Agent
Bonus/muedjk.htm");
userData[9] = new Array("jthrelfall", "jeff1", "Agent
Bonus/uehdlo.htm");

function Login() {
var username=document.login.username.value.toLowerCase();
var password=document.login.password.value.toLowerCase();

for (i=0; i<userData.length; i++) {
if (username==userData [0] && password==userData [1]) {
window.open(userData [2]);
return true;
}
}
alert("Invalid Login!");


}


</script>

</head>
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
oglegroups.com>, Wed, 3 Jan 2007 21:12:28, Anthony
function Login() {
var username=document.login.username.value.toLowerCase();
var username=document.login.password.value.toLowerCase();

for (i=0; i<userData.length; i++) {
if (username==userData [0] && password==userData [1]) {
window.open(userData [2]);
return true;
}
}
alert("Invalid Login!");
}


Anyone apart (from the most ignorant or constrained) who can see the Web
page containing that code can also see, in its source, all the
usernames, their passwords, and the locations that they are to be sent
to. It's like putting the front door key on a string dangling just
behind the letter-box.

It's a good idea to read the newsgroup and its FAQ. See below.
 
A

Anthony

Anthony said:
I copied the script directly from his usenet posting. The only
modification that I made was to the second " in the <script
type=""text/javascript">> tag. This works for users sbazell,
cryjohnson, jthrelfall but gives the Invalid Login alert for everyone
else. I am not recieving the error message however when I preview in
FP. Could something else be wrong? Here is the script from my page:

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Login Page</title>
<meta name="Microsoft Theme" content="boldstri 1011, default">
<meta name="Microsoft Border" content="t, default">

<script type="text/javascript">

var userData = new Array()
userData[0] = new Array("sbazell", "0513", "Agent
Bonus/aknram.htm");
userData[1] = new Array("techambers", "Chambers1", "Agent
Bonus/xplojh.htm");
userData[2] = new Array("afrye", "AJPMF1998", "Agent
Bonus/yxjgrv.htm");
userData[3] = new Array("thead", "Blessed07", "Agent
Bonus/jnsihy.htm");
userData[4] = new Array("cryjohnson", "kittycat6", "Agent
Bonus/xdowud.htm");
userData[5] = new Array("rckenley", "Baller", "Agent
Bonus/vxjuye.htm");
userData[6] = new Array("nmock", "Dimonds4ever", "Agent
Bonus/zzojkl.htm");
userData[7] = new Array("gnimley", "Qwejue", "Agent
Bonus/hsoywm.htm");
userData[8] = new Array("vestewart", "TD3301", "Agent
Bonus/muedjk.htm");
userData[9] = new Array("jthrelfall", "jeff1", "Agent
Bonus/uehdlo.htm");

function Login() {
var username=document.login.username.value.toLowerCase();
var password=document.login.password.value.toLowerCase();

for (i=0; i<userData.length; i++) {
if (username==userData [0] && password==userData [1]) {
window.open(userData [2]);
return true;
}
}
alert("Invalid Login!");


}


</script>

</head>
Anthony said:

The code he posted works without errors.

You either copied it incorrectly or your error is elsewhere.
Create the simplest page you can make that shows the error.
It shouldn't be more than about 40 lines of code.

If you don't find the error while doing that, post the entire
simplified page so we can test your exact code.


--
 
A

Anthony

Thanks for the concern Dr. J however this code is being used for a team
website on a company intranet. The idea is to have basic security; I
don't really need anything else. The information contained in the
sheets to which my agents are sent is readily available to anyone who
is willing to manually calculate bonus information. This is just for
the benefit and fun of my employees.
In comp.lang.javascript message <[email protected]
oglegroups.com>, Wed, 3 Jan 2007 21:12:28, Anthony
function Login() {
var username=document.login.username.value.toLowerCase();
var username=document.login.password.value.toLowerCase();

for (i=0; i<userData.length; i++) {
if (username==userData [0] && password==userData [1]) {
window.open(userData [2]);
return true;
}
}
alert("Invalid Login!");
}


Anyone apart (from the most ignorant or constrained) who can see the Web
page containing that code can also see, in its source, all the
usernames, their passwords, and the locations that they are to be sent
to. It's like putting the front door key on a string dangling just
behind the letter-box.

It's a good idea to read the newsgroup and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. [email protected] Turnpike v6.05 IE 6
FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
 
T

Ted Zlatanov

Thanks for the concern Dr. J however this code is being used for a team
website on a company intranet. The idea is to have basic security; I
don't really need anything else. The information contained in the
sheets to which my agents are sent is readily available to anyone who
is willing to manually calculate bonus information. This is just for
the benefit and fun of my employees.

The illusion of security is worse than no security at all. What you
call basic security (it's not, btw) is thus worse than displaying all
the information on a single page, because people may believe there is
some security involved.

Basic realm authentication is really easy to set up. You should do
that, it will save you and everyone else headaches in the future.

Ted
 
A

Anthony

I am open to suggestions but also very new at javascript. Could
explain BRA more clearly for me. What about using a javascript include
file so that the source code including the username and password
combinations were not viewable? Would that work any better?
 
A

Anthony

I am open to suggestions but also new at javascript. I am teaching
myself how to use it starting with the basics. Could you explain BRA a
little more clearly for me. And what if I use an include file so that
the username and password combinations were not viewable in the source
code. Would that work any better?
 
T

Ted Zlatanov

I am open to suggestions but also very new at javascript. Could
explain BRA more clearly for me. What about using a javascript include
file so that the source code including the username and password
combinations were not viewable? Would that work any better?

Please don't top-post.

BRA is really easy to set up, but the exact mechanism depends on your
webserver. With Apache 1.3, you can follow this guide:

http://httpd.apache.org/docs/1.3/howto/auth.html

or any of the numerous HOWTO documents you can google. Internally, it
works with special HTTP headers that are part of the HTTP protocol.

Ted
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top