a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Hosting from $3.99 per month!

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions. dd

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

passing variable through login page

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> passing variable through login page
Page: [1]
 
jgeatty

 

Posts: 199
Joined: 10/14/2004
Status: offline

 
passing variable through login page - 4/7/2005 20:33:34   
here's the deal... i have a site where some pages need to be "secure" so not everyone can make changes to them. i have a page that you can click on "edit information" and it takes you to the editrecord.asp page. but if you aren't logged in already it takes you to the login page first, which all works great. the problem is it isn't passing the variable to the editrecord.asp page after the user logs in. instead of passing http://iss.kp.org/serverdep/newserverform/editrecord.asp?ServerName=CSCRDKRON004
it is only passing http://iss.kp.org/serverdep/newserverform/editrecord.asp

any ideas?
Spooky

 

Posts: 26617
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: passing variable through login page - 4/7/2005 20:37:35   
Using my login? If not - the same theory applies :

Response.redirect "/login.asp?Redirect=" &Request.Servervariables("URL") &"?" &Request.Servervariables("QUERY_STRING")

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to jgeatty)
dzirkelb1

 

Posts: 1321
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: passing variable through login page - 4/8/2005 10:55:15   
Or, you can store it in a cookie to avoid passing the variable to each page:

Response.Cookies("Login")=whateveritis

(in reply to Spooky)
jgeatty

 

Posts: 199
Joined: 10/14/2004
Status: offline

 
RE: passing variable through login page - 4/8/2005 14:33:11   
I am actually using a Microsoft "How to Use a Database for User Names and Passwords in FrontPage 2000" (http://support.microsoft.com/kb/321503). But anyway, it uses the following two lines at the top of the page(s) to see if you are logged in, and if not it redirects you to the login page:
<% @language="vbscript" %>
<!--#include virtual="/serverdep/newserverform/logon/_private/logon.inc"-->


The cookie theory sounds interesting, but I have never used them before. What would I do to use them?

(in reply to dzirkelb1)
dzirkelb1

 

Posts: 1321
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: passing variable through login page - 4/8/2005 14:59:40   
To set the cookie, its usually something like this:

login page, has simple username / password field that posts to another page, lets call it loginconfirmation.asp

Its code is something like this:

fp_sQry="SELECT Username, Password FROM TABLE WHERE (Username='"&trim(request.form("Username"))&"') AND (Password='"&trim(request.form("Password"))&"')"

<%Response.Cookies("Username")=fp_field(fp_rs,"Username")%> (put this after the include file 1 and before include file 2)

That sets the cookie...then, for top of each page, put this:

<%
if Request.Cookies("Username")="" then
Response.Redirect"login.asp"
end if
%>

(in reply to jgeatty)
jgeatty

 

Posts: 199
Joined: 10/14/2004
Status: offline

 
RE: passing variable through login page - 4/8/2005 15:19:30   
so i use this instead of the vbscript lines that i am using now at the top of the page?

(in reply to dzirkelb1)
dzirkelb1

 

Posts: 1321
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: passing variable through login page - 4/8/2005 15:37:52   
If yo choose to do so, yupp

(in reply to jgeatty)
jgeatty

 

Posts: 199
Joined: 10/14/2004
Status: offline

 
RE: passing variable through login page - 4/8/2005 16:16:02   
Any ideas how I would be able to use the current code I have now so I don't have to change all of my pages? Here is the include file code:
<%
  ' Do not cache this page.
  Response.CacheControl = "no-cache"

  ' Define the name of the users table.
  Const USERS_TABLE  = "tblUsers"
  ' Define the path to the logon page.
  Const LOGON_PAGE   = "/serverdep/newserverform/logon/logon.asp"
  ' Define the path to the logon database.
  Const MDB_URL      = "/serverdep/newserverform/logon/_private/logon.mdb"

  ' Check to see whether you have a current user name.
  If Len(Session("UID")) = 0 Then
    ' Are you currently on the logon page?
    If LCase(LOGON_PAGE) <> LCase(Request.ServerVariables("URL")) Then
      ' If not, set a session variable for the page that made the request...
      Session("REFERRER") = Request.ServerVariables("URL")
      ' ...and redirect to the logon page.
      Response.Redirect LOGON_PAGE
    End If
  End If

  ' This function checks for a username/password combination.
  Function ComparePassword(UID,PWD)
    ' Define your variables.
    Dim strSQL, objCN, objRS
    ' Set up your SQL string.
    strSQL = "SELECT * FROM " & USERS_TABLE & " WHERE (UID='" & UID & "' AND PWD='" & PWD & "');"
    ' Create a database connection object.
    Set objCN = Server.CreateObject("ADODB.Connection")
    ' Open the database connection object.
    objCN.Open "driver={Microsoft Access Driver (*.mdb)}; dbq=" & Server.MapPath(MDB_URL) & "; uid=admin; pwd="
    ' Run the database query.
    Set objRS = objCN.Execute(strSQL)
    ' Set the status to true/false for the database lookup.
    ComparePassword = Not(objRS.EOF)
    ' Close your database objects.
    Set objRS = Nothing
    Set objCN = Nothing
  End Function
%>


And here is the code on my login page that is supposed to forward the user to the original url they wanted to access:
<%
  ' Was this page posted to?
  If UCase(Request.ServerVariables("HTTP_METHOD")) = "POST" Then
    ' If so, verify the username/password that was entered.
    If ComparePassword(Request("UID"),Request("PWD")) Then
      ' If comparison was good, store the user name...
      Session("UID") = Request("UID")
      ' ..and redirect back to the original page.
      Response.Redirect Session("REFERRER")
    End If
  End If
%>


Any ideas? Thanks for the help as usual!:)

(in reply to dzirkelb1)
dzirkelb1

 

Posts: 1321
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: passing variable through login page - 4/8/2005 16:22:16   
You have to store the username and password in some sort of database that will call the results and make sure it all works...


check out www.msultd.com/kfc/login.asp and put in schlutzkevin as the username, and temp as the password...once your logged in, fool around if you choose (its not live), and close the browser. Then, try to go to www.msultd.com/kfc/welcome.asp and it will redirect you to the login.

If this is what you are looking for, then I can post my codes and bold the items you need to change.

(in reply to jgeatty)
dzirkelb1

 

Posts: 1321
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: passing variable through login page - 4/8/2005 16:28:21   
Login.asp page:
<form method="POST" action="loginconfirmation.asp">

	<div align="center">
	<table border="0" width="200">
		<tr>
			<td>Username</td>
			<td> <input type="text" name="Username" size="20"></td>
		</tr>
		<tr>
			<td>Password</td>
			<td> <input type="password" name="Password" size="20"></td>
		</tr>
		<tr>
			<td colspan="2" align="center">
			<input class="button" type="submit" value="Login" name="Login"><input class="button" type="reset" value="Reset" name="B2"></td>
		</tr>
	</table>


loginconfirmation.asp
<!--#include file="../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT Username, Password, Email, PhoneNumber, Operator FROM tblDistinctOperators WHERE (Username='"&trim(request.form("Username"))&"') AND (Password='"&trim(request.form("Password"))&"')"
fp_sDefault="Username=&Password="
fp_sNoRecords="<tr><td colspan=2 align=""LEFT"" width=""100%"">Incorrect Username or Password...please try again</td></tr>"
fp_sDataConn="KFC"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&Username=202&Password=202&"
fp_iDisplayCols=2
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<%Response.Cookies("Email")=fp_field(fp_rs,"Email")%>
<%Response.Cookies("PhoneNumber")=fp_field(fp_rs,"PhoneNumber")%>
<%Response.Cookies("Username")=fp_field(fp_rs,"Username")%>
<%Response.Redirect"successfulllogin.asp"%><!--#include file="../_fpclass/fpdbrgn2.inc"-->
(I added cookies for email and phone number for mine)

Now, for each page that you want "protected", you place this code on the top:

<%
if Request.Cookies("Username")="" then
Response.Redirect"login.asp"
end if
%>

Thats your protection...if you choose to pull data depending on who is logged in, then your where clause would look like:

WHERE (Name='"&Request.Cookies("Username")&"')

hope that helps

(in reply to jgeatty)
jgeatty

 

Posts: 199
Joined: 10/14/2004
Status: offline

 
RE: passing variable through login page - 4/8/2005 16:45:51   
if you could give me your code for your login that would be great!!!

(in reply to dzirkelb1)
dzirkelb1

 

Posts: 1321
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: passing variable through login page - 4/8/2005 16:50:03   
see above :)

(in reply to jgeatty)
jgeatty

 

Posts: 199
Joined: 10/14/2004
Status: offline

 
RE: passing variable through login page - 4/8/2005 17:07:05   
what about the <%Response.Redirect"successfulllogin.asp"%>? what is this page?

(in reply to dzirkelb1)
dzirkelb1

 

Posts: 1321
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: passing variable through login page - 4/8/2005 17:12:21   
oh, woops, I do that to keep track of how many times they log in...if your interested, it is
<!--#include file="../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="UPDATE tblDistinctOperators SET SuccessfullLogins = (SuccessfullLogins+1) WHERE (Operator='"&Request.Cookies("Username")&"')"
fp_sDefault=""
fp_sNoRecords=""
fp_sDataConn="KFC"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&"
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<!--#include file="../_fpclass/fpdbrgn2.inc"-->


<%Response.Redirect"welcome.asp"%>


otherwise, do the response.redirect to whatever your main page is or wherever you wisht them to go after they log in

(in reply to jgeatty)
jgeatty

 

Posts: 199
Joined: 10/14/2004
Status: offline

 
RE: passing variable through login page - 4/8/2005 17:15:50   
is there a way to pass them to the original page they were trying to go to, or do they have to login and start over?

(in reply to dzirkelb1)
dzirkelb1

 

Posts: 1321
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: passing variable through login page - 4/8/2005 17:19:15   
Hrmm, never tried that but definately makes sense to impliment....not sure, but this may work:

on the top of each page (before the script to ensure they are logged in) try putting this:

<%
response.cookies("CurrentPage")="http://www.mydomain.com/wherever.asp"
%>

Now, on your redirect, have it be:

response.redirect"&request.cookies("CurrentPage")

I think that should work, but not sure...you would have to change the link on top of each page. It has to be before the redirect of the script to see if they are logged in though.

taking off for the day, hope it works :)

(in reply to jgeatty)
jgeatty

 

Posts: 199
Joined: 10/14/2004
Status: offline

 
RE: passing variable through login page - 4/8/2005 18:17:08   
this is a really dumb question, but i forget how to do it. i want to display a line of code when it is ouputed to the browser so i can see what the result of the asp is. what is the code for this again?

(in reply to jgeatty)
dzirkelb1

 

Posts: 1321
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: passing variable through login page - 4/8/2005 18:36:59   
<%=whatever%>

or

<%response.write("whatever")%>

(in reply to jgeatty)
Page:   [1]
OutFront Discoveries

All Forums >> Web Development >> ASP and Database >> passing variable through login page
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts