weixin_33711641 2018-02-01 16:10 采纳率: 0%
浏览 24

1个按钮Same Value 2个动作

I have 2 forms that i need to merge, so that i only have a searchbox and one submit button. Maybe this is simple but i just don´t know how to do it.

The forms :

<form action="http://www.wixfilters.com/Lookup/Exactmatch.aspx?" method="get" target="_blank">
    <input name="PartNo" type="text" value="" />
    <input type="submit" value="Procurar" />
</form>

<form action="https://catalog.cumminsfiltration.com/catalog/CatalogSearch.do?&quot;" method="get" target="_blank">
    <input name="partNumber_PartDeatils" type="text" value="" />
    <input type="submit" value="Procurar" />
</form>

The value to search is the same, example search for 24073.

  • 写回答

2条回答 默认 最新

  • lrony* 2018-02-01 16:27
    关注

    Assuming the user doesn't need to go to the webpage you can use a cURL

    for example make a form called submit.php in the same directory as your HTML file and change your form to this:

    HTML FORM

    <form action="submit.php" method="post" target="_blank">
    <input name="partNumber_PartDeatils" type="text" value="" />
    <input name="PartNo" type="text" value="" />
    <input type="submit" value="Procurar" />
    </form>
    

    Then you submit.php file looks like this:

    submit.php

    <?php
    
    $partNumber_PartDeatils = $_POST['partNumber_PartDeatils'];
    $PartNo = $_POST['PartNo'];
    
    $curl = curl_init();
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_URL,"http://www.wixfilters.com/Lookup/Exactmatch.aspx");
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, "var1=$PartNo");
    
        curl_exec ($curl);
        curl_close ($curl);
    
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_URL,"https://catalog.cumminsfiltration.com/catalog/CatalogSearch.do?&quot");
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, "var2=$partNumber_PartDeatils");
    
        curl_exec ($curl);
        curl_close ($curl);
    

    If you need to handle the response data form two external URLs you are going to struggle and perhaps need to reconsider your site architecture.

    评论

报告相同问题?

悬赏问题

  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?