Closed Thread Icon

Topic awaiting preservation: Password problem (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8683" title="Pages that link to Topic awaiting preservation: Password problem (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Password problem <span class="small">(Page 1 of 1)</span>\

 
Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-01-2003 05:55

Hi, guys. Hello again.
Well, I have got an another question! What I am doing is simple:

If user click on button, prompt box pops up. Then password has to be put in. If user put long password, he has to try it again. If they put correct password, which is Hiroki, in the text box, "Hiroki is in New Zealand now" appears.

Here is my code:

code:
<html>
<head>
<script type="text/javascript">
function guessIt()
{
var pass="Hiroki";
var ans = 0;
while (ans != pass)
{
ans = prompt(Enter the password")
}

document.theForm.info.value=document.write("Hiroki is in New Zealand now.")
}
</script>
</head>
<body>
<form name="theForm">
<h3>Get Information about him!</h3>
<p>
<input type="button" name="clickMe" value="Click here" onClick="guessIt()">
<input type="text" name="info">
<p/>
</form>
</body>
</html>



I thought I did right. But it didn't work. And I cannot see any problem.
Do you see any?(..~)

Hiroki Kozai

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 06-01-2003 06:09

Just change

document.theForm.info.value=document.write("Hiroki is in New Zealand now.")

to

document.theForm.info.value="Hiroki is in New Zealand now."

document.write is only used by itself, while the page is loading. (or after the page has loaded in order to create a *new* page.)

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-01-2003 07:04

Hi, Slime.
Many thanks for your reply.
I did like you said.
But I am afraid not work.....
Hhm......Would you see anything else????

Hiroki Kozai

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 06-01-2003 07:48

Oh, you're also missing a quote in

prompt(Enter the password")

Did you check JavaScript errors?

viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 06-01-2003 08:09

You are really not going to use this code to protect something, are you? The password is in the code!

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-02-2003 03:58

Thanks for your advices, guys.
Hi, Slime. Yes, I did.
When I got an error, I always did it.
But I couldn't figure out....
And Viol!
It is good point.
This code is actually just practice from book.
Can I ask you one question?

Do I manage to get through server side scripting to make proper password field like a lot of web site. For example here ozoneasylum?

Hiroki Kozai

viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 06-02-2003 06:20

Hiroki, I am not an expert in this matter but as far as I understand, using client side, the best you could do is to store the password in a cookie and this is not safe at all, since cookies are just text files that can be easily read, for instance, by Netscape or Mozilla.
For a secure login, you need server-side and some database to store the password/login data. And for all that secure stuff that you usually see in professional sites, you need a secure server, those that usually use https:// instead of http:// in the address bar and make a lock show up in the status bar.
For a less secure login, but good enough for personal uses, you can use the built-in features of the Apache server (.htaccess/htpasswd files), to set up some restricted folders in your website.

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-02-2003 07:18

Hi, viol. Many many thanks for your reply.
I understand that.
And it was like I imagined.
I want to be able to make professinal site like you said in my future.
For now, I am getting my hands dirty with JavaScript and basic stuff.
Cya.

Hiroki Kozai

« BackwardsOnwards »

Show Forum Drop Down Menu