Passing login values issue ??? test1.asp?name =value???

M

Miranda johnsen

Hello,

I need some help with passing a value from my login authorization page.
The authorization is done with the code below (it works), but I need the
'uName' value passed on when the window.location is activated.

I code my ASP with JavaScript NOT vbscript so please no &'s. And yes I
know I should be using a DSN-less connection! ((sorry, everytime I post
I get blasted about my syntax and connection choice :+))

I am slightly baffled with query's and this is what I have tried:
============= taken from code below ==================
var memid;
memid = Request.form("uName");
//Response.write(memid);//THIS PRINTS OUT FINE!!!
Response.write("<SCRIPT
Language=\"../clientside/clientnewstest1.asp?MemberID=+memid\";</SCRIPT>
");//THIS DOES NOT!!
=============================================

==========================================
======== THE WHOLE SECTION ==========
==========================================

var conn;
var rs;
var sSQL;

conn=Server.CreateObject("ADODB.Connection");
rs=Server.CreateObject("ADODB.Recordset");
conn.Open("cpWebdata");

sSQL = "SELECT InvestorAdmin.*";
sSQL += " FROM InvestorAdmin ";
sSQL += " WHERE MemberID = '" + Request.Form("uName") + "' ";
sSQL += " AND MemberPW = '" + Request.Form("uPass") + "';";


rs=Server.CreateObject("ADODB.Recordset");
rs.Open(sSQL, conn);
//Response.write(sSQL); THIS RETURNS MemberID='undefined'

if (!rs.eof) {
//User Validated as a record exists in recordset


var memid;
memid = Request.form("uName");
//Response.write(memid);
Response.write("<SCRIPT
Language=\"../clientside/clientnewstest1.asp?MemberID=+memid\";</SCRIPT>
");
} else {
//Not a valid username or password - THIS WORKS FINE
Response.write("<SCRIPT Language=JavaScript>window.location =
\"loginportfolio.asp\";</SCRIPT>");


rs.close();
conn.close();
rs=null;
conn=null;
}
=================================================
=============== END CODE ===================
===============================================

One more thing. My login page is used for two different databases - I
test for one, if false test for the other and if thats false they are
not allowed in. This works, but I just need that one value to go with
it!!
I would appreciate any help with this :+)
Thanks in advance, Miranda
 
T

Tom B

Two things that I noticed immediately.
1) Shouldn't it be Language=Javascript rather than
Language=../clientside/etc.
2) memid needs to be outside of the quotes if you wish to concatenate it's
value.
Response.write ("yada yada yada" + memid);
 
M

Miranda johnsen

Thanks Tom,

whoops, cut&paste error there :+s

So, This area is the main prob: ?memberid=+memid\";
I'm not sure what you mean about the quotes???
This is a slight re-write of what I thought I pasted in :+s
Response.write("<script
language=Javascript>window.location=\"../clientside/clientnewstest1.asp?
memberid=+memid\";</script>");

Thanks, MJ
 
T

Tom B

Sorry I haven't got back sooner.
Response.Write("the text to be written"); is the format for
Response.Write --- as you know.
The engine will write whatever's in quotes as is. Therefore, to send the
value of a variable, it needs to be appended outside of the quotes....

Response.Write("Hello" + fName); Where fName is a variable containing the
value you want sent..

So in your code
Response.write("<script
language=Javascript>window.location=\"../clientside/clientnewstest1.asp?
memberid=+memid\";</script>");

memid - a variable - is within the quotes of
Response.write("<SCRIPT...........+memid\";</SCRIPT>");
Where I think it should be......
Response.write("<script
language=Javascript>window.location=\"../clientside/clientnewstest1.asp?
memberid=" + memid + "\";</script>");

Easier still.....

<script language=Javascript>

window.location="../clientside/clientnewstest1.asp?memberid=<%Response.Write
(memid);%>";
</script>
 

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,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top