...

View Full Version : posting using server side script



ShMiL
04-02-2006, 01:03 PM
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

degsy
04-03-2006, 02:17 PM
You could use XMLhttp
http://www.4guysfromrolla.com/webtech/110100-1.2.shtml




<%@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


<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
%>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum