posting info to a remote server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • garethharvey
    New Member
    • Apr 2008
    • 14

    posting info to a remote server

    I have a page that processes a request from affiliates, the form processed the info and writes it to our database.

    How can I tell the affiliate if the process was successful or not?

    Is there something I could write at the end of the process for them to collect?
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Gareth,

    There are many ways you can communicate with a third party via an automated process. Possibilites include:
    1. Sending an e-mail
    2. Sending data via ftp
    3. Submitting a form to a webpage of the affiliates
    Do any of these sound like they may be suitable?

    Dr B

    Comment

    • garethharvey
      New Member
      • Apr 2008
      • 14

      #3
      Thanks Dr B

      this is the scenario:

      I have a form processor on our server that received the info and then processes it into our database. The affiliates post the info to us from their websites as follows:

      Code:
      DataToSend = "instruct=instruct&quotationnumber="&quotationnumber&"&partnerid="&partnerid
      
      dim xmlhttp 
      set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
      xmlhttp.Open "POST","http://www.myserver.co.uk/xmlfeed/instruct.asp",false
      xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
      xmlhttp.send DataToSend		'send data in the form of a query string
      Set xmlhttp = nothing
      Once this task is completed their page continues to run as normal, but I want to send something back to say if it was successful or not.

      So I am looking for maybe another line of code after processing the form that they can read to verify the process has been completed.

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        Have you considered posting some data back in the same way as they have sent it?

        Comment

        • garethharvey
          New Member
          • Apr 2008
          • 14

          #5
          Thanks Dr B

          Tried a few things but modified the code to:

          Code:
           dim xmlhttp 
          set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
          xmlhttp.Open "POST","http://www.website.co.uk/xmlfeed/instruct.asp",false
          xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
          xmlhttp.send DataToSend	
          status = xmlhttp.status 
          if err.number <> 0 or status <> 200 then 
          if status = 404 then 
          			post_instruction="error_404" 
          elseif status >= 401 and status < 402 then 
          			post_instruction="error_401" 
          elseif status >= 500 and status <= 600 then 
          			post_instruction="error_500" 
          else 
          			post_instruction="error" 
          end if 
          else
          	post_instruction="completed" 
          end if
          	End If
          Set xmlhttp = nothing
          This then returns an error if the form failed. All sorted now.
          Last edited by DrBunchman; Apr 18 '08, 12:16 PM. Reason: Added code tags - note the # button

          Comment

          • DrBunchman
            Recognized Expert Contributor
            • Jan 2008
            • 979

            #6
            OKay Gareth, glad you got it sorted out.

            Comment

            • garethharvey
              New Member
              • Apr 2008
              • 14

              #7
              Just spotted another problem, the information being posted is:

              e.g.

              Mr Gareth Harvey

              but is getting written to the database as:

              MrGarethHarvey

              It's stripping out all the spaces? Don't know why

              Comment

              • DrBunchman
                Recognized Expert Contributor
                • Jan 2008
                • 979

                #8
                Do you mean the data that you are receiving?

                There's probably two places where the spaces are being removed: whilst being passed to your page or while being passed into your database update.

                Can you test the recieved data (i.e. response.write it to the page) after it's been received initally and do the same just prior to it being passed into your update statement.

                Hopefully you should be able to see where the spaces have been removed.

                Dr B

                Comment

                • garethharvey
                  New Member
                  • Apr 2008
                  • 14

                  #9
                  The infor is being cleaned prior to sending, so a simple replace " ","+" solved the problem.

                  Comment

                  Working...