View Full Version : Passing an ERROR string to next page??? HELP?!?

08-01-2007, 02:05 AM
I am using ASPemail (http://aspemail.com) on a site, and I can get it to work fine when the form posts back to itself. My "sucess" statement shows just fine when I register on the site, and my email goes through perfectly.

But what I want to do is display a different page (other than the same form page) with either a "thank you" dialog or the printout of the error message should there be one.

I can't figure out how to reference the error string ("strErr") to the confirmation.asp page. I've put the script, exactly as on the "register.asp" page, in the confirmation.asp page and it doesnt work. In fact, when the form is submitted it redirects to confirmation.asp, but the page is not displayed at all.

Is there an easy way to pass a variable that is NOT set in the form itself (i.e. just a variable of the page)?

I've tried using <% = Request("strErr") %>, <% =strErr %>, etc., and nothing works. In the register.asp page it is simply <% =strErr %>.

Can anyone help? All of the code needed can be found at the site above.

Thanks alot

08-01-2007, 12:52 PM
Use session variables.

All variables are destroyed upon page completion except Session and Application. Application variables are available to EVERYONE, while Session variables are for that particular person.

So, for you, set session("strErr") = strErr. Then, on your Confirmation page, use <%= session("strErr") %> when needed.

When you are done using it, use Session.Contents.Remove("strErr") OR session("strErr") = "".

These will destroy the session variable.


08-01-2007, 03:22 PM
Thanks for the reply.

I was trying to avoid having to use session state, since this is just a registration form and nothing too complex.

But if I were to do what you said, where would I put the session("strErr") = strErr?

08-01-2007, 05:02 PM
If you want to keep variables persistent across pages, you have no choice but to use session variables (that is, unless you really want to hate life and put the strErr into a hidden HTML input field and then use the Request object. yuk...)

May I safely assume that this thread is similar/related to this thread?

If so, then here's what you are looking for:

On your Register.asp :

session("strErr") = ""
session("bSuccess") = False
On Error Resume Next ' catch errors
Mail.Send ' send message
If Err <> 0 Then ' error occurred
session("strErr") = Err.Description
session("bSuccess") = True
End If

On your Confirmation.asp :


<% If session("strErr") <> "" Then %>
<h3><div align="center"><FONT COLOR="#FF0000">Error occurred: <I><% = strErr %></I></FONT></div></h3>
End If %>

<% If session("bSuccess") = true Then %>
<div align="center"><FONT COLOR="#00A000">
Thank you for registering, <% =Request.Form("name") %>!
End If %>


If you are still having issues with it, just let us know!

08-01-2007, 08:57 PM
Are you talking about having the form on pageA submit to pageB and then if there is an Error on pageB have that move to pageC? If that is the case include the error in a hidden form field and use javascript and the pageload event to handle the movement from one page to another. or if you are moving using Response.Redirect then put the error in the querystring and simply request it once on pageC.

If there is no 3rd page involved then you do not need to pass it to the next page since this is the page you are on!!!.

Read my reply in the other thread.