Redirecting

J

Jim

Can anyone tell me with this code?

At the moment I enter an email into index.html and when I click submit the
email address passes to add_email.asp which writes the email to email.xml.
Have a look - www.madtim67.com

The code then shows the xml file on screen but I want to redirect it to
another page (just back to index.html). I've tried a few things but none of
them seem to have the desired effect.


add_email.asp
--------------

<% @LANGUAGE = "VBScript" %>

<%

Dim xmlFile
Dim xmlRoot
Dim xmlNode
Dim strTitle
Dim strError
Dim strPath

strPath = Server.MapPath("db/email.xml")

Set xmlFile = Server.CreateObject("Microsoft.XMLDOM")
xmlFile.Async = False

If Not xmlFile.Load(strPath) Then
Call Server.Transfer("invalid.html")
End If

Set xmlRoot = xmlFile.DocumentElement

Set xmlNode = xmlFile.CreateElement("message")
Call xmlNode.SetAttribute("timestamp", Now)
Call xmlRoot.AppendChild(xmlNode)

Set xmlRoot = xmlNode

Call CreateElementNode("user","userName",xmlNode)

Call xmlFile.Save(strPath)

Call Server.Transfer("db/email.xml")

Sub CreateElementNode(elementName, formElement, node)

Set xmlNode = xmlFile.CreateElement(elementName)
xmlNode.Text = Request(formElement)
Call xmlRoot.AppendChild(node)

End Sub

%>

P.S can anyone help me with checking to see if the email address entered
already exists in email.xml
 
B

Bo

Jim,

Your call 'Call Server.Transfer("db/email.xml")' does just that - the
server stops executing your ASP script (presumably add_email.asp) at
that point and switches to executing email.xml instead. All the server
does with email.xml is to send it to the browser. So your code after
that Server.Transfer call never gets executed.

What you would do is to put Call Server.Transfer("index.html") as your
very last statement. And do whatever you intend to to with email.xml
before that.

/Bo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top