Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts

    posting using server side script

    I want to post (like form: method=post) through the server.
    response.redirect doesn't pass parameters (and I don't want to put them on the URL).
    Server.Transfer only works in the same server, and I want to post to a page on another server.

    Any idea?

    Thanks

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You could use XMLhttp
    http://www.4guysfromrolla.com/webtech/110100-1.2.shtml

    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%
    If Len(Request.Form) > 0 Then
    dim strResponse,destURL,strContent
    
    destURL = "http://domain.com/script.asp"
    Response.Write destURL
    'Construct the Post Data
    strContent = strContent & "name=" 	& server.URLencode(Request.Form("name"))
    strContent = strContent & "&pass=" 	& server.URLencode(Request.Form("pass"))
    
    'Construct the useragent and send 
    set http_obj=server.CreateObject("MSXML2.ServerXMLHTTP")    
    http_obj.Open "POST", destURL , false 
    http_obj.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
    http_obj.send(strContent)
    
    
    'Grab the response
    strResponse = http_obj.ResponseText
    
    set http_obj=nothing 
    Response.Write "Form sent"
    response.write( strResponse )
    
    End If
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    
    <body>
    <form name="form1" method="post" action="">
      <p>Name: 
        <input name="name" type="text" value="joe">
    </p>
      <p>Pass: 
        <input name="pass" type="password" value="1234">
    </p>
      <p>
        <input type="submit" name="Submit" value="Submit">
      </p>
    </form>
    </body>
    </html>
    script
    Code:
    <H1>Thankyou for posting data</H1>
    <p>Here are the results</p>
    <%
    For Each Item In Request.Form
    	Response.Write Item & ": " & Request.Form(Item) & "<br>"
    Next
    %>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •