|
| |
|
|
hawleyr
Posts: 23 Joined: 8/24/2007 Status: offline
|
Redirect and Form Fields - 9/14/2009 15:27:16
I read the other thread over this topic and it was very helpful. I've run into a little snag and hope someone can provide me with an answer in as lay terms as possible since I'm still new to this. I've got a form page, let's say Z, that I want a visitor to be redirected away from to another page (Y) if a specific field is blank. Page Y contains a form that passes three variables over to page Z's form. So, I don't want people just blindly entering data into those matching fields on Z unless page Y has been visited. Currently I have this located at the header on page Z redirecting people to page Y (Begin_Data.asp) if the field Last_Name is blank. <%if field="Last_Name" = 0 Then
Response.Redirect "Begin_Data.asp"
End if%>
<% Response.CacheControl = "no-cache" %>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %> This works (too well). If I go directly to page Z, I get dumped to Begin_Data.asp since Begin_Data passes over the field Last_Name. If a person hasn't visited Begin_Data first like I want them to, then that field will be blank on page Z. The Begin_Data.asp is a searchable form for a person to find their name and verify their info. Once they click continue, three fields have their data passed to page Z. The fields are First_Name, Last_Name and Institution. My problem is that when I find my info on Begin_Data.asp and click continue, I keep getting re-directed to Begin_Data. It is as if page Z fails to see the carried over values and keeps reading the Last_Name field as empty and redirecting back to Begin_Data.asp. If I remove <%if field="Last_Name" = 0 Then
Response.Redirect "Begin_Data.asp"
End if%> then the fields pass over correctly. What am I doing wrong? Is there a fix or workaround for my problem? Is there a way to say if Last_Name has a value then do nothing? Or is it just that my method will never see a carried value?
|
|
|
|
hawleyr
Posts: 23 Joined: 8/24/2007 Status: offline
|
RE: Redirect and Form Fields - 9/15/2009 12:51:18
Well I figured out another way around this making use of the http referer: I made a page a page called referer.asp that contains the code:
<%
Dim sResult
sResult = InStr( 1, Request.ServerVariables("HTTP_REFERER"), _
"//your_host_name/your_app_path/", 1)
if sResult = 0 or sResult = Null then
Response.Redirect("desired_redirect_page.htm")
End If
%>
I then put this code into the header of each file I don't want people accessing without hitting my redirect page first:
<%@ LANGUAGE = VBSCRIPT%>
<%Option Explicit%>
<!-- #INCLUDE file="referer.asp" -->
So far, so good. Everything works exactly as it should!
|
|
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
|
|
|