...

View Full Version : enter two variables at page entry prompt



tpeck
10-14-2006, 02:46 PM
I don't know how to even begin going about this, but it seems to be a fairly simple request.

I'm looking for a prompt dialog at a certain page that doesn't check a database for registered users (well that would be nice but is not vital).

What it would do is ask for two pieces of information (User name and Password if you like) and allow the page to retrieve those two pieces of information and use them as variables within the page.

If anyone can direct me to a place where something of this kind is discussed, I would be very grateful.

Thanks,

tpeck
10-14-2006, 06:44 PM
This seems to do one variable:

<script>
var whatName=prompt("Please enter your name:","");
function doName(theName){
if ((whatName != "")&&(whatName !=null)){
document.writeln("Hello "+whatName+"!")
}else{
document.writeln("Hello!")
}
}
doName(whatName);
</script>

***************************************

Would it be feasible to change the else statement to block entry to the page if something isn't entered? Like, it just keeps popping up until something is entered or Cancel takes the user somewhere pre-defined?

tpeck
10-15-2006, 01:59 AM
This seems to do much that I wanted in case anyone else was interested:

<SCRIPT LANGUAGE="JavaScript">
//
//Login Script Prompt
//

/// Functions() (NON-EDITABLE)

function LogIn(){
loggedin=false;
username="";
password="";
username=prompt("Username:","");
username=username.toLowerCase();
password=prompt("Password:","");
password=password.toLowerCase();

/// Login Names and P-words (EDITABLE)

if (username=="user001" && password=="1234") {
loggedin=true;
window.location="http://nmba.usa.tripod.com";
}
if (username=="user002" && password=="1234") {
loggedin=true;
window.location="http://nmba.usa.tripod.com";
}

/// Alert for incorrect (EDITABLE BUT NOT RECOMENDED)

if (loggedin==false) {
alert("Login failed!\n\nPlease supply new credentials.");
}
}

</SCRIPT>

VortexCortex
10-15-2006, 04:01 AM
I just wanted to thank you for learning something on your own!

I have noticed that most times the questions posted have been answered in the archives...

Also, thanks for posting your progress on the solution.

A few times I have posted a lengthy script only to find out the author fixed the problem, but did not reply...

-------

You do realize that if someone clicks "view source" they will be able to see the user names and passwords contained in your script....

tpeck
10-15-2006, 09:17 AM
Well, I didn't want to leave it half hanging... (can't claim I worked it all out either).

For my purposes, it doesn't matter that the input is insecure; but thanks a lot for pointing it out.

Actually, in the end I didn't use this method - I settled for a form input method that passed variables to another page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum