...

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



Punkcrib
08-01-2007, 01: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

Daemonspyre
08-01-2007, 11:52 AM
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.

HTH!

Punkcrib
08-01-2007, 02: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?

Daemonspyre
08-01-2007, 04: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?
http://www.codingforums.com/showthread.php?t=119836

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
else
session("bSuccess") = True
End If


On your Confirmation.asp :



<body>

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

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

</body>


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

miranda
08-01-2007, 07: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum