Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing varibles to other pages to be used in SQL

Status
Not open for further replies.

scottbacca

Technical User
Aug 30, 2001
6
NZ
Hi,

I'll try to be brief but descriptive with my problem.

I have a login page with two textboxes, UserName and Password.

I need to pass the value entered in the UserName field to another page (menu.asp) which then passes the value onto yet another page (week1.asp or week2.asp)
On this second page (week1.asp or week2.asp) there is a form and when a user submits the information on this form, the UserName value is needed in an sql insert into statement. It is only needed at this point and no other.

how do i pass the username between the forms so i can use it later down the track. Is there such a thing as a global variable?? I'm using VBScript.

thanks
Scott
 
Hi,
On the page u r entering username and password..

to put values in session variables..U don't have word like global variables..

U have session variables..In which when taken last long through the session

U have application variables..In which when taken last long through the life of application in ue case
session is best suited

session("username") = txtusername.value
session("password") = txtpass.value


and retrive the values from any form in the project

strusername = session("username")
str pass = sessuin("password")

from the variables to can any task u want

hope u got it
all the best

 
Make sure to set your session variables to 'nothing' when you are done. If you make extensive use of them within your pages without cleaning them up, you will begin to see a degredation in performance.

 
BlueIndian1...

Is that as simple as this?
set session("myVariable")=nothing

-Dennis =====================
Dennis B

Remember - YOU ARE UNIQUE!!!... Just like EVERYONE ELSE! ;o)
 
Hi again,

BlueIndian - when do i set my session variables to nothing and how? Do i need to create a logout form?

Is it as easy as how dennis the menace described above?

Thanks eveyone for your help.
 
Yeah that's the easiest way, create a logout form and kill the session variables there. Here's mine, it's simple.

<%
Session.Abandon
Response.Redirect &quot;../default.asp&quot;
%>

:)
 
wouldn't session.abandon kill all of the session variables?
 
If you have access to your global.asa file, you can create a global session variable when the person first accesses your site automatically, and then also automatically clean up your variables when they leave.

In the global.asa file you would:
Code:
Sub Session_OnStart
 FrontPage_StartSession
 (Run Script to get values)
 SET txtusername = (value)
 SET txtpass = (value)
End Sub
Then when they leave create a Session.OnEnd Sub to clean up only those values you just set.

Access those values in your pages such as:
Code:
Session(&quot;txtusername&quot;)
Session(&quot;txtpass&quot;)
You're done
bc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top