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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Hidden Fileds to track users

Status
Not open for further replies.

ufobaby

MIS
Sep 25, 2001
238
US
hi, one more newbie question

am so far having three pages
1.] logscr.htm (has username and pwd textboxes and it uses "post" to auth.asp)
2.] auth.asp (has ASP code to check the user and Redirect to welcome.html, which works fine.)
3.] welcome.html which will have links and .....

Ok, what i want to do is use a hidden field in welcome.html to store the username through out, but not in the query string (welcome.html?item=niraj) OR session variables. Also the welcome.html should check before loading whether the user is loggeg in through the logscr.html or no.

Also donot want to avoid the auth.asp in between as i might use this for more than one site. Is this possible. Any workaround to this will surely do

Regards
Niraj [noevil]
 
<input type=hidden name=username value = <%=Username%> >

Note that due to the additionof some asp code to the welcome page, the extention will have to change to .ASP

hth

Bastien Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Bastien, thks for the time
i know this but
But in my auth.asp am using
Response.Redirect welcome.asp
so how would the <%Username%> get populated.am pasting the code for the 3 files below. this would give a better idea ->
<- logscr.htm ->
----------------
<html>
<body>
<form method=&quot;POST&quot; action=&quot;auth.asp&quot;>
<p>Username <input type=&quot;text&quot; name=&quot;uname&quot; size=&quot;20&quot;></p>
<p>Password <input type=&quot;text&quot; name=&quot;pwd&quot; size=&quot;20&quot;></p>
<p><input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;B1&quot;><input type=&quot;reset&quot; value=&quot;Reset&quot;
name=&quot;B2&quot;></p>
</form>
</body>
</html>
<- auth.asp ->
--------------
<%
Dim ConLog 'For Opening Connection to Db
Dim rs 'For RecordsSet
Set ConLog = Server.CreateObject(&quot;adodb.connection&quot;)
ConLog.Open &quot;Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\user.mdb&quot;
Set rs = ConLog.Execute(&quot;select * from usr where username='&quot; & _
request.form(&quot;uname&quot;) & &quot;' and password='&quot; & request.form(&quot;pwd&quot;) & &quot;'&quot;)
if rs.eof=true then
Response.Redirect &quot;logscr.htm&quot;
else
Response.Redirect &quot;welcome.asp&quot;
end if
%>
<- welcome.htm ->
-----------------
<html>
<body>
<p align=&quot;center&quot;>You Have Successfully Logged in etc</p>
</body>
</html>

Could u suggest some thing ***urgently***. and am done with rest of the stuff.
Regards
Niraj [noevil]
 
try this: instead of sending the user to another page with a redirect, use a Sub End Sub routine to print the html to the user

if rs.eof=true then
'Response.Redirect &quot;logscr.htm&quot;
response.write &quot;You are not located. Please register below&quot;
response.write &quot;<form name = register action = register.asp method = post>&quot;
'additional code to show the page goes here
else


response.write &quot;<html>
<body>
<p align=&quot;center&quot;>You Have Successfully Logged in etc</p>
<form name = loggedIn method = post>
<input type=hidden name = user value = <%=username%>>
</body>
</html>

One way to do this is to have one page here with SUB END SUBs as many as you like and then just call the subs to display the same data as called by your different pages:

if isNull(request.form(&quot;user&quot;)) then
call register()
elseif (request.form(&quot;userID&quot;)<>&quot;&quot; and request.form(&quot;password&quot;)) then
call logged()
elseif not isNull(request.form(&quot;user&quot;)) and AnOtherVar then
call AnotherSub()
end if

Sub register()
'code to show registration form

End Sub

Sub Logged()
Dim ConLog 'For Opening Connection to Db
Dim rs 'For RecordsSet
Set ConLog = Server.CreateObject(&quot;adodb.connection&quot;)
ConLog.Open &quot;Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\user.mdb&quot;
Set rs = ConLog.Execute(&quot;select * from usr where username='&quot; & _
request.form(&quot;uname&quot;) & &quot;' and password='&quot; & request.form(&quot;pwd&quot;) & &quot;'&quot;)

if rs.eof=true then
call register()
else
call welcome()
end if
END SUB

SUB welcome()

<html>
<body>
<p align=&quot;center&quot;>You Have Successfully Logged in etc</p>
<form name = loggedIn method = post>
<input type=hidden name = user value = <%=username%>>
'some code for menu choices
</body>
</html>
END SUB

%>

You might get one really long page, but it should do everything your site does...but really the session variable is the way to go, better easier to hold

hth

Bastien


Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Bastien, appreciate u r efforts,

but after looking at such a lengthy workaround i would better use the session variables. cause my welcom page would have a lot of links and frames and stuff so i guess it would really become messy.

Actually i read on lot of posts that session variables r not really as good as they sound, and so was confused a bit as this is my first ASP project u c.

Anyways Thanks a ton for ur help. Now i can get going
Thanks & regards
Niraj [noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top