Redirecting

Discussion in 'XML' started by Jim, Jun 7, 2006.

  1. Jim

    Jim Guest

    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
     
    Jim, Jun 7, 2006
    #1
    1. Advertising

  2. Jim

    Bo Guest

    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

    Jim wrote:
    > 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
     
    Bo, Jun 9, 2006
    #2
    1. Advertising

  3. Jim

    jim Guest

    Thanks very much, i cant believe I never saw that.


    Bo wrote:
    > 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
    >
    > Jim wrote:
    >> 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

    >
     
    jim, Jun 11, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon Landenburer

    redirecting stderr and stdout

    Jon Landenburer, May 12, 2004, in forum: Perl
    Replies:
    1
    Views:
    11,217
    Joe Smith
    May 13, 2004
  2. Sune Hansen

    Site keeps redirecting

    Sune Hansen, Jun 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    375
    Sune Hansen
    Jun 30, 2003
  3. Leslie McGann
    Replies:
    0
    Views:
    2,087
    Leslie McGann
    Jul 3, 2003
  4. Dan M
    Replies:
    3
    Views:
    531
    Dan M
    Jul 9, 2003
  5. Steve C. Orr, MCSD

    Re: redirecting from .aspx page to .asp page

    Steve C. Orr, MCSD, Jul 15, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    415
    Steve C. Orr, MCSD
    Jul 15, 2003
Loading...

Share This Page