PHP 表单发布到 ASP.NET ASPX 页面?

发布于 2024-12-06 06:24:33 字数 1015 浏览 0 评论 0原文

我有三个收集少量表单数据的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

メ斷腸人バ 2024-12-13 06:24:33

我正在做一些ATM机类似的事情。我正在使用包含简单

的 HTML 文件测试我的代码,起初它不起作用,因为我使用的是id 属性,因为我认为 name 属性已被弃用。事实证明,它仅适用于 Request.Form("X") 其中 。希望这有帮助。

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 with Request.Form("X") where <input type="text" name="X" />. Hope this helps.

南城旧梦 2024-12-13 06:24:33

您是否尝试过此操作并且遇到问题?或者只是问是否可以?

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 use Request.Form("somefieldname")

避讳 2024-12-13 06:24:33

我已经编写了从客户应用程序接收 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文