dtkago3208 2011-01-25 21:55
浏览 62

提交表单商店响应

I have a form the lies on a server I do not have control of. Lets call it form1. I know the POST requirements of form1. I am creating my own form to submit data to that form1. Lets call that one form2. Form1 returns a ticket number, I need to store that ticket number into a department database, along with other information (that part I am ok with). So I need form2(my form) to submit data to form1(ITs form) and store the response from form1 into our department database.

What is the easiest way to do this? I have searched online for hours, and have come up empty. I went from javascript to iFrame to Ajax to jQuery. And I am just lost now.

My server is a PHP server, theirs is a ASP server.

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • douliao5467 2011-01-25 22:18
    关注

    This is not a client-side operation, it is a server side operation. There is no need for "form2". You want to use curl for this. Something like this:

    // Set up a connection to the target of form1 (this is the "action" attribute of form1)
    $curl_connection = curl_init('http://hostname.com/form1.asp');
    
    // Set up so options -- connection timout, store to string, follow redirects
    curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
    
    // Set the post fields, this is just like a query string and contains the contents of form1 fields
    curl_setopt($curl_connection, CURLOPT_POSTFIELDS, "field1=value1&field2=value2");
    
    // Run the query and capture the results
    $data = curl_exec($curl_connection);
    curl_close($curl_connection);
    
    // At this point $data should contain the ticket number
    var_dump($data);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了