PDA

View Full Version : Cannot pass login info to the next .asp page(s)



foreigner737
Jun 2nd, 2010, 09:16 PM
Hi coders,

I have a login form which has the following code:



<p>
Username:<span><input type="text" id="uid" name="uid" size="14"/> </span>
Pass:<span><input type="password" id="pwd" name="pwd" size="14"/></span>
<a onclick="return loginload()" href="#" class="btn">Enter</a>


Here is the loginload script directs me to the following page upon Enter:



function loginload() {
window.location="step1.asp";
}


Now that step1.asp gets the user & pass variables and pass them to step2.asp page that way:



<html>
<!-- #include file="include/common.asp" -->
<!-- #include file="include/security.asp" -->
<head>
<meta http-equiv="Content-Language" content="tr">
<meta name="GENERATOR" content="Microsoft FrontPage 12.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<title>Login</title>
</head>

<body background="webimages/BGS/Gray.jpg" bgcolor="#D6D6DE" topmargin="2" leftmargin="35" oncontextmenu='return false' ondragstart='return false' onselectstart='return false'>
<form name="frm1" method="post" action="step2.asp">
<input type="hidden" name="_uid" id="_uid">
<input type="hidden" name="_pwd" id="_pwd">
</form>

<SCRIPT>
document.forms[0]._uid.value = document.getElementById("uid").value;
document.forms[0]._pwd.value = document.getElementById("pwd").value;
document.forms[0].submit();
</script>

</body>

</html>



After clicking on Enter on the login page, I receive the error for the step1.asp page:

Line:20
Char:1
Object Required
Code:0
Url=step1.asp

Line 20 is the beginning of the script.


Could not figure it out.
Any opinions/advise are wellcome.

Old Pedant
Jun 2nd, 2010, 10:21 PM
<p>
Username:<span><input type="text" id="uid" name="uid" size="14"/> </span>
Pass:<span><input type="password" id="pwd" name="pwd" size="14"/></span>
<a onclick="return loginload()" href="#" class="btn">Enter</a>
...
function loginload() {
window.location="step1.asp";
}

Won't work. Disaster.

You are *NOT* sending those form field values to the next page!!!

When you use window.location= like that, it is the SAME THING as the user typing that URL into the address bar of their browser. So *NONE OF THE INFORMATION* from the current page is sent to "step1.asp".

WHY would you do it this way in any case???

Why wouldn't you just use

<form action="step1.asp" method="post">
<p>
Username:<span><input type="text" id="uid" name="uid" size="14"/> </span>
Pass:<span><input type="password" id="pwd" name="pwd" size="14"/></span>
<input type="submit" value="Enter"/>
</form>

Old Pedant
Jun 2nd, 2010, 10:23 PM
Your code in step1.asp is also very wrong.

You can't expect to use

document.getElementById("uid").value
to get a value from the PRIOR PAGE!!! document *MEANS* the CURRENT PAGE.