|
| |
|
|
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?
|
|
|
|
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
|
|
|
|
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?
|
|
|
|
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 %>
|
|
|
|
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?
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
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
|
|
|
|
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!!!
|
|
|
|
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 :)
|
|
|
|
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?
|
|
|
|
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
|
|
|
|
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?
|
|
|
|
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 :)
|
|
|
|
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?
|
|
|
|
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")%>
|
|
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
|
|
|