2014-06-04 70 views
0

如果在引用頁面上輸入的驗證碼不正確,我想返回幾個可能頁面之一。這就是我正在嘗試的,當它出現錯誤時它會繞過重定向並將它們帶到成功頁面。如果我把的Response.Redirect(「SomePage.asp中」),它的工作原理沒有問題,但我需要它來處理多頁參照網址響應重定向上一頁經典asp

Call ValidateCAPTCHA() 
If m_CAPTCHAPASS<>1 then 
Session("ValidCAPTCHA")="false" 
Dim redirectpage 
redirectpage = Request.ServerVariables("HTTP_REFERER") & "e=1" 
Session("FirstName")=Request.Form("First_Name") 
Session("Phone")=Request.Form("Phone") 
Session("EMail")=Request.Form("EMail") 
Session("Comments")=Request.Form("Comments") 
response.redirect(Request.redirectpage) 
end if 
'send email script follows 
+0

你可以驗證裏面的'Request.ServerVariables(「HTTP_REFERER」)'?只需將其輸出到頁面即可。 –

+0

好吧,我發現我的錯誤....與引用附加e = 1應該已經是?e = 1 ...現在的問題是,多次提交錯誤驗證碼後,它不斷追加參數: http:// www .somesite.com/recommendationspage.asp?e = 1 然後變成 http://www.somesite.com/referringpage.asp?e=1?e=1 等等 – user2129560

回答

1

按照您的意見,以防止多個參數此外,只檢查是否已經添加參數。像這樣:

Dim redirectpage 

redirectpage = Request.ServerVariables("HTTP_REFERER") 
If Right(redirectpage, 4) <> "?e=1" Then redirectpage = redirectpage & "?e=1" 
'.... the rest of the code 
+0

這樣做,謝謝! – user2129560