navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

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

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

Microsoft MVP

 

redirect back to previous 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 >> redirect back to previous page
Page: [1]
 
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
redirect back to previous page - 2/14/2005 12:10:20   
I am trying to redirect back to the previous page whatever it may be. Can that be done? I can elaborate if need be. Thanks in advance.
Spooky

 

Posts: 26560
Joined: 11/11/1998
From: Middle Earth
Status: online

 
RE: redirect back to previous page - 2/14/2005 12:37:21   
Has the current page been posted to by a form? how did the user get there and why redirect?

_____________________________

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

§þ:)


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: redirect back to previous page - 2/14/2005 12:42:11   
Well I have a page with a list of links to all our queries on our intranet. This list is available to everyone. So when a user clicks on a certain query I have it refresh to my security access page which determines whether the user has access. If the flag is "Y" then they get the msg that states they don't have access, if it is "N" then I want to redirect them to the page they came from(the link they originally clicked on). Is that possible? I can show you some code if you like. Thanks for the quick reply by the way!

(in reply to Spooky)
rdouglass

 

Posts: 9137
From: Biddeford, ME USA
Status: offline

 
RE: redirect back to previous page - 2/14/2005 12:50:33   
Maybe:

Response.redirect(Request.servervariables("HTTP_REFERER"))

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: redirect back to previous page - 2/14/2005 12:54:13   
I tried the HTTP_REFERER and it says A URL is required. Any ideas?

(in reply to rdouglass)
Spooky

 

Posts: 26560
Joined: 11/11/1998
From: Middle Earth
Status: online

 
RE: redirect back to previous page - 2/14/2005 12:57:17   
"I have it refresh to my security access page "

Not too sure what you are doing there - the user is redirected to a security page?

_____________________________

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

§þ:)


(in reply to rrnml)
rdouglass

 

Posts: 9137
From: Biddeford, ME USA
Status: offline

 
RE: redirect back to previous page - 2/14/2005 13:01:03   
quote:

I tried the HTTP_REFERER and it says A URL is required. Any ideas?


Also, if you're just typing the URL in the browser, that message will display IIRC.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to Spooky)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: redirect back to previous page - 2/14/2005 13:02:50   
Ok I'll explain what the whole thing is about. I have a bunch of queries that I need to lock down access to. I have a list of who has access to what. So instead of using a login or putting a boat load of code into every query, I have one page(security access page) that has the code to determine whether or not the user has access. So instead of putting all that code into every query I only put a meta tag that refreshes each query to the access page. Then the access page sees if it's either a "Y" or "N". If it's a "Y" you don't have access and if it's an "N" I want to send it back to the page it originally wanted to go to. And I just thought of something every time it send it back even if it is possible, it will just keep refreshing. Crap! Any other ideas from you guys? I really should have thought that through. Sorry about that.............

(in reply to Spooky)
rdouglass

 

Posts: 9137
From: Biddeford, ME USA
Status: offline

 
RE: redirect back to previous page - 2/14/2005 13:05:39   
A coupla' thoughts:

1. Passing the URL (or some other parameter) with a querystring or hidden field?

2. Persistent data with a cookie or session value?

Those any good?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: redirect back to previous page - 2/14/2005 13:07:39   
I will definitely see if either those might work. Thanks.

(in reply to rdouglass)
dzirkelb1

 

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

 
RE: redirect back to previous page - 2/14/2005 13:10:09   
--------------------------------------------------------------------------------
You can pass a Session variable that would define which user is logged in and only display their results (would call the variable in your sql query). Or, you can work with cookies and configure it that way...I have no clue on cookies, but session variables are fairly easy.

Example (change items in bold)

login.asp--place username / password here and post to confirmation.asp

confirmation.asp--

<%Session("Username")=request("Username")%> (place at top of page under body)

Place this on all of your pages that contain data you wish to restrict to the user who is logged in...this is optional.
<%if Session("Username")="" then%>
<script>
window.location="login.asp"
</script>
<%end if%>

fp_sQry="SELECT Username, Password FROM table WHERE (Username='::Username::') AND (Password='::Password::')"


Now, on all of your pages after this that contain the data you wish to restrict, you need to do the following in your sql code:

fp_sQry="SELECT * FROM table WHERE (Field='"&Session("Username")&"')
Thats an option for ya...hope it points you in the right direction :)

(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: redirect back to previous page - 2/14/2005 13:14:58   
Hey thanks guys. I am going to take this information to my partner and see if we can get it working. I really appreciate the suggestions. Any other ideas are definitely welcome. I was hoping it would be simple, but that just means I'll have to think a little harder about this one! Thanks again to all of you.

(in reply to dzirkelb1)
dzirkelb1

 

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

 
RE: redirect back to previous page - 2/14/2005 13:19:35   
If your looking for simplicity over security...then I suggest the following:

Have a login page, where it requests a username and password.

Post it to the page you wish to display the links for the queries.

Have this page display the username / password you logged in with by the drw...now, change the table around so the results that display inside the drw are the links and get rid of the actual username / password being shown. That way, if they put in an invalid password or username, it will display no records returned or whatever you wish to show.

The sql query is simple for the confirmation page that shows the links...it is simply select username, password from table where (username='::username::') and (password='::password::')

Then, you could have one login name / password if you choosed for everyone with access.

(in reply to rrnml)
Spooky

 

Posts: 26560
Joined: 11/11/1998
From: Middle Earth
Status: online

 
RE: redirect back to previous page - 2/14/2005 13:20:50   
Im not convinced :)
It seems you need to identify the user each time to see if they have access to the query?
How do you identify the user and the queries they have access to?

_____________________________

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

§þ:)


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: redirect back to previous page - 2/14/2005 13:23:39   
I'm grabbing the remote_user session variable and comparing it to a file on our AS400. This is where the list of users is defined and what queries they have access to.

(in reply to Spooky)
Giomanach

 

Posts: 6075
Joined: 11/19/2003
From: England
Status: offline

 
RE: redirect back to previous page - 2/14/2005 13:24:17   
<% Response.Write ("<body onLoad='javascript: location.go(-1);'>") %>

Or something like that...can be altered to an anchor tag etc, but would something like that do it?

_____________________________




(in reply to Spooky)
Spooky

 

Posts: 26560
Joined: 11/11/1998
From: Middle Earth
Status: online

 
RE: redirect back to previous page - 2/14/2005 13:27:51   
If it were me - then I would use an include on each page that checks for access.
eg :
<!-- #include file="chkuser.asp" -->

That file would contain the lookup for the secure page and compare the user, redirecting if access is not allowed.
Either that, or depending how many users, just perform the comparison on the page.

eg :

<%If request.servervariables("remote_user") <> "AXA/AX1234" then response.redirect .......

_____________________________

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

§þ:)


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: redirect back to previous page - 2/14/2005 13:33:33   
Where would I put the include? I will show you the code for the security page. I know it's kind of crazy and convoluted, but here goes..............

<%
'Check to see if the user is authorized to access this query.

Dim strParm8
Dim strParm9
Dim strParm10
Dim errorflag

Dim rst9
Dim strSQL9

strParm8 = Request.ServerVariables("Remote_User")
strParm9 = Mid(strParm8,8,15)
'Response.write strParm9

'This field needs to exactly match the qrname field in the qrynamp file on the AS400
'strParm10 is the name of this query

strParm10 = "CM/DM Query"

Const adOpenKeyset = 0
Const adLockOptimistic = 1

'Create the objects
Set con = Server.CreateObject("ADODB.Connection")
Set rst9 = Server.CreateObject("ADODB.Recordset")

' Open the connection to the AS400 Database

'con.Open "Secondary", "user1", "password1"
con.Open "Primary", "user1", "password1"

con.CommandTimeout = 0

' Create the SQL Query String
' User Access Query String
strSQL9 = "select nmddta.qrynamp.qruser, nmddta.qrynamp.qrname, nmddta.qrynamp.qrflag " & _
" from nmddta.qrynamp Where nmddta.qrynamp.qruser = '" & strParm9 & "' and nmddta.qrynamp.qrname = '" & strParm10 & "'"
'Response.write strSQL9

server.ScriptTimeOut = 600
Set rst9 = Server.CreateObject("ADODB.Recordset")
rst9.Open strSQL9, con, adOpenKeyset, adLockOptimistic

IF NOT rst9.EOF then

errorflag = rst9("qrflag")
'Response.write errorflag

''The query has been restricted using the AS400 Security menu selections.

If errorflag = "N" Then

Response.redirect


Else

Response.write strParm9
Response.write " <br> This query has been temporarily restricted...Please notify Security and your immediate supervisor for access."

End If

Else

Response.write strParm9
Response.write " <br> This query has been temporarily restricted...Please notify Security and your immediate supervisor for access."

End If
%>

<%
rst9.Close
con.Close
%>

(in reply to Spooky)
Spooky

 

Posts: 26560
Joined: 11/11/1998
From: Middle Earth
Status: online

 
RE: redirect back to previous page - 2/14/2005 13:46:28   
Id try and make that code the include
Ive tidied up a portion of it below to try and clarify?

 IF NOT rst9.EOF then
	errorflag = rst9("qrflag")

	If errorflag = "N" Then
		Response.redirect "error.htm"
		'here you will redirect as the user doesnt have access
	Else
		Response.write strParm9
		Response.write " <br> This query has been temporarily restricted...Please notify Security and your immediate supervisor for access."
		' here you will do nothing and allow the page display to continue
		
	End If
Else
	Response.redirect "error.htm"
	'here you will redirect as the user has not been found
End If 




_____________________________

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

§þ:)


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: redirect back to previous page - 2/14/2005 13:56:14   
Ok I know this is confusing and I'm getting a little confused myself! And to let you know, I didn't write the code orginally, I was just directed to make it work! It seemed backwards to me at first. So basically if there is an errorflag ( errorflag = "Y") then that means the user does not have access therefore he will get the msg to contact security or supervisor for access. If the is not an errorflag ( errorflag = "N") then that means the user does have access and should be directed to the page they are looking for. So now looking at your code, I'm confused. Can you clarify with the info I just gave you? Thanks and sorry about my confusion, I'm still very new to ASP.

(in reply to Spooky)
Spooky

 

Posts: 26560
Joined: 11/11/1998
From: Middle Earth
Status: online

 
RE: redirect back to previous page - 2/14/2005 14:06:31   
Yes - that is a bit backwards, it kinda read they other way :-)

IF NOT rst9.EOF then
	errorflag = rst9("qrflag")

	If errorflag = "N" Then
		' do nothing, the page will display
	Else
		Response.write strParm9
		Response.write " <br> This query has been temporarily restricted...Please notify Security and your immediate supervisor for access."
		Response.end
	End If
Else
	Response.redirect "error.htm"
	'here you will redirect as the user has not been found
End If


_____________________________

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

§þ:)


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: redirect back to previous page - 2/14/2005 17:35:11   
Ok guys. I've tried all the suggestions aside from the login one. We're trying to avoid them having to enter a password again. Though they were great suggestions, they didn't seem to work. I am thinking I may have to place this piece of code into every query. It's been tested and it does work that way. I guess I just wanted to find a simpler way of doing it. Anyway thanks for your help, I really do appreciate it. I'm going to get started with this code. In the meantime, I will continue to search for a simpler way. Thanks again guys!

(in reply to rrnml)
Spooky

 

Posts: 26560
Joined: 11/11/1998
From: Middle Earth
Status: online

 
RE: redirect back to previous page - 2/14/2005 17:42:50   
When you say "didnt work" what happened?


_____________________________

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

§þ:)


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: redirect back to previous page - 2/14/2005 17:57:44   
Well, when I change the flag for my user to Y it works, but when I change it to N. The page is just blank.

(in reply to Spooky)
Spooky

 

Posts: 26560
Joined: 11/11/1998
From: Middle Earth
Status: online

 
RE: redirect back to previous page - 2/14/2005 18:12:49   
The included code - what did you end up using? (paste the code here :)

_____________________________

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

§þ:)


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: redirect back to previous page - 2/14/2005 18:26:25   
This is what I have in there. Still working on it.


' Create the SQL Query String
' User Access Query String
strSQL9 = "select nmddta.qrynamp.qruser, nmddta.qrynamp.qrname, nmddta.qrynamp.qrflag " & _
" from nmddta.qrynamp Where nmddta.qrynamp.qruser = '" & strParm9 & "' and nmddta.qrynamp.qrname = '" & strParm10 & "'"
'Response.write strSQL9

server.ScriptTimeOut = 600
Set rst9 = Server.CreateObject("ADODB.Recordset")
rst9.Open strSQL9, con, adOpenKeyset, adLockOptimistic

'The query has been restricted using the AS400 Security menu selections.

IF NOT rst9.EOF then
errorflag = rst9("qrflag")

If errorflag = "N" Then
' do nothing, the page will display
Else
Response.write strParm9
Response.write " <br> This query has been temporarily restricted...Please notify Security and your immediate supervisor for access."
Response.end
End If
Else
Response.redirect "error.htm"
'here you will redirect as the user has not been found
End If
%>

<%
rst9.Close
con.Close
%>

(in reply to Spooky)
Spooky

 

Posts: 26560
Joined: 11/11/1998
From: Middle Earth
Status: online

 
RE: redirect back to previous page - 2/14/2005 18:31:28   
Try this code - I do notice however that you dont have a connection string?

<%

con = "?????"
strSQL9 = "select nmddta.qrynamp.qruser, nmddta.qrynamp.qrname, nmddta.qrynamp.qrflag " & _
" from nmddta.qrynamp Where nmddta.qrynamp.qruser = '" & strParm9 & "' and nmddta.qrynamp.qrname = '" & strParm10 & "'"

Response.write strSQL9

server.ScriptTimeOut = 600
Set rst9 = Server.CreateObject("ADODB.Recordset")
rst9.Open strSQL9, con, 1,1 

IF NOT rst9.EOF then
errorflag = rst9("qrflag")

If errorflag = "N" Then
' do nothing, the page will display
response.write "error flag=N"
Else
Response.write strParm9
Response.write " <br> This query has been temporarily restricted...Please notify Security and your immediate supervisor for access."
Response.end
End If
Else
Response.write "here you will redirect as the user has not been found"
End If

rst9.Close
con.Close
%>


_____________________________

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

§þ:)


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: redirect back to previous page - 2/14/2005 18:37:35   
I do have the connection string, I just didn't put it all out there. I'm going to take this home with me and see if I can get it to work. If not I will be bugging you tomorrow!!! Thanks so much Spooky. You are a great Moderator!

(in reply to Spooky)
Spooky

 

Posts: 26560
Joined: 11/11/1998
From: Middle Earth
Status: online

 
RE: redirect back to previous page - 2/14/2005 18:55:41   
Feel free to bug away ;-)
The extra code I put in there should write some infor to the page, youll then be able to see which parts of the code will run.

_____________________________

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

§þ:)


(in reply to rrnml)
stone5150

 

Posts: 1
Joined: 5/1/2008
Status: offline

 
RE: redirect back to previous page - 5/1/2008 21:58:48   
Here is a simple way to do that

Session("HTTP_Referer") = request.servervariables("HTTP_Referer")
Response.Redirect( Session("HTTP_Referer") )

(in reply to Spooky)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> redirect back to previous 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