473,405 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Anybody can help me on this javascript program Please.

nyy
This is a program that is supposed to save the user name and password
in cookies, and when the user comes back to login and he enters the
same user name and password, a pop up message welcome him or her. If
after three tries the user don't enter the same User/pass, let the user
knows it is his or her time on the page. Thanks and here is so far what
I have. help is appreciate it. Thanks again.

<HTML>
<HEAD>
<TITLE>Badia</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function LogIn(){
loggedin=false;
username="";
password="";
username=prompt("Username:","");
password=prompt("Password:","");

if (username=="" || password=="")
{
alert("Invalid login, please try again!");
}
if (username!="" && password!="");
{
alert("Your user name and password has been saved!");
}
}
</SCRIPT>
</HEAD>

<BODY>
<center>
<h1>WEB 420 </h1>
<h2>Badia</h2>
</center>

<center>
<form><input type=button value="Login!" onClick="LogIn()">
</form>
</center>

</BODY>
</HTML>

Sep 17 '05 #1
2 1430
nyy wrote:
This is a program that is supposed to save the user name and password
in cookies, and when the user comes back to login and he enters the
same user name and password, a pop up message welcome him or her. If
after three tries the user don't enter the same User/pass, let the user
knows it is his or her time on the page. Thanks and here is so far what
I have. help is appreciate it. Thanks again.


Where are the <input>s for the username and password?

What is the "prompt()" function that you attempt to call?

Where are you doing *anything* with cookies?

Why would you save username and password in something as unsecure as
cookies?

Sep 17 '05 #2
> If after three tries the user don't enter the same User/pass, let the user
knows it is his or her time on the page.
What does that mean?
username=prompt("Username:","");
password=prompt("Password:","");

if (username=="" || password=="")
{
alert("Invalid login, please try again!");
}
Your next step would be to put the above in a loop
to repeat it if necessary. To have been given such
an assignment, you must have been taught about
loops. I would not bother with an alert here:

while( ( username=prompt("Username:","") )== "" )
;

If the user closes the dialog, prompt() returns
'undefined', but don't worry about that for now.

if (username!="" && password!="");
{
alert("Your user name and password has been saved!");
}
}


Again I would assume that you must have been
introduced to using cookies. I think for this
exercise, session cookies would be adequate
and their availability can be assumed.

document.cookie="cookieName=" + cookieValue;

document.cookie is a string comprised of all the
cookies for the current domain, each delimited by
a semicolon. The trick is to find the position of
yours, perhaps using String.indexOf(), then using
that as a starting point to extract the value on
the other side of the '=' sign.

--
S.C.

Sep 17 '05 #3

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

Similar topics

9
by: andrew | last post by:
Hi, I posted this message recently, but received no response, so I figured I'd try again. I can't find anybody who can tell me what's going on here. I'm having a problem with fieldsets in IE...
4
by: DOTNET | last post by:
Hi, Anybody help me regarding this error: I am assigning the values to the session variables when the button is clicked and passing these session variables to the next page and when I am...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
32
by: Tom Cole | last post by:
I bet 50% of the posts I've read lately have had at least one bad thing to say about every website or book dedicated to javascript. There are clearly a few posters (you know who you are) who...
36
by: aljamala | last post by:
Hi, I keep getting this warning on a page, but I do not know what the problem is...does anyone have an idea about what could be wrong? line 88 column 7 - Warning: missing </formbefore <td> it...
5
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually...
0
by: wxscooter | last post by:
OK, this is frustrating. I want my VB6 program to use Webbrowser to fill out info on a page. One of the things I need to do is click an arrow to transfer an item from one text box to another. I...
1
by: lilbit02 | last post by:
Hi, I have a form that utilizes validation as most do via javascript. This form worked totaly fine until I needed to add a dynamic div now the validation doesn't work. It does work for the first...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.