PHP 表单发布到 ASP.NET ASPX 页面?
我有三个收集少量表单数据的 PHP 网站。我想将这些 PHP 页面的操作设置为发布到 ASP.NET(另一个实例)网站。
在 ASPX 方面,在页面加载时,我正在查找表单集合,并用它在 SQL 中执行一些操作。
我认为 ASPX 页面只能接收来自另一个网站的表单帖子?我离基地太远了吗?有想法吗?
执行帖子的 PHP 代码片段(我认为)
$host = "www.myaspnetwebsite.com";
$port = 80;
$path = "/leads.aspx";
//send the server request
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $poststring . "\r\n\r\n");
//loop through the response from the server
while(!feof($fp)) {
$response .= fgets($fp, 4096);
}
//close fp - we are done with it
fclose($fp);
该表单位于 HTML 页面上,具有上面的 PHP 操作(片段)。文件中还有更多内容,但这看起来像是这篇文章的内容。
<form action="process-final.php" method="post" id="in-quote-form">
I have three PHP web sites that collect a small amount of form data. I want to set the action of these PHP pages to post to the ASP.NET (another instance) web site.
On the ASPX side, on page load, I'm looking for the form collection, and doing some stuff in SQL with it.
I thought that an ASPX page could just receive a form post from another web site? Am I way off base? Ideas?
The snippet of PHP code that does the post (I think)
$host = "www.myaspnetwebsite.com";
$port = 80;
$path = "/leads.aspx";
//send the server request
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $poststring . "\r\n\r\n");
//loop through the response from the server
while(!feof($fp)) {
$response .= fgets($fp, 4096);
}
//close fp - we are done with it
fclose($fp);
The form is on an HTML page with action of the PHP (snip) above. There's more in the file, but that looks like what's doing the post.
<form action="process-final.php" method="post" id="in-quote-form">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我正在做一些ATM机类似的事情。我正在使用包含简单
I'm doing something along these lines ATM. I'm testing my code with a HTML file containing a simple
<form method="post" action="targetpage.aspx">
, at first it didn't work because I was using the id attribute because I thought the name attribute was deprecated. It turns out though that it only works withRequest.Form("X")
where<input type="text" name="X" />
. Hope this helps.您是否尝试过此操作并且遇到问题?或者只是问是否可以?
在
Page_Load
事件中,您可以使用Request.Form("somefieldname")
Have you tried this and you are having a problem? Or just asking if it's possible?
In the
Page_Load
event you can useRequest.Form("somefieldname")
我已经编写了从客户应用程序接收 POST 数据的 asp.net 应用程序,因此我可以向您保证您尝试做的事情是可能的。
您确定 asp.net 应用程序工作正常吗?如果您尝试对要 POST 的资源发出 GET 请求,会发生什么情况?
你能发布你的 php 应用程序的打开表单标签吗?该操作是否是完全限定的域名(即 http://www.example.com/customers)?我不相信相对 URL 会起作用,除非应用程序共享目录结构。
我们需要更多信息才能真正帮助您确定这一点。
I've written asp.net applications that receive POST data from my customer's applications, so I can assure you that what you are trying to do is possible.
Are you sure the asp.net application is working correctly? What happens if you attempt a GET request to the resource you are trying to POST to?
Can you post the opening form tag of your php application? Is the action a fully qualified domain name (i.e. http://www.example.com/customers)? I don't believe a relative url will work unless the applications share a directory structure.
We need a bit more information to really help you nail this down.