doutuo7609 2014-08-25 13:43
浏览 101
已采纳

如何将表单数据发送到两个或更多PHP文件?

I have a Form in an HTML page like below that is sending my data to a page at http://www.aaaaaa.com/1st-file.php...

<form action="http://www.aaaaaa.com/1st-file.php" method="post" enctype="plain" id="theForm">   
<input type="text" name="NAME" value="Some Data" />
<input type="submit" value="Send Data" />
</form>

But I want to send the same data on http://www.bbbbbb.com/2nd-file.php. My form is on HTML page and I want to send data via one click on Send Data only. So is this possible to send data on both PHP pages using pure JavaScript not JQuery? If yes then how?

Update:

My both PHP receiving files have codes something like below...

<?php
$data_from_site= $_POST['NAME'];
echo $data_from_site;
?>
  • 写回答

3条回答 默认 最新

  • duanfuchi7236 2014-08-25 13:55
    关注

    Use an iframe as described here,

    <input type="submit" value="Send Data" onclick='javascript: return SubmitForm()' />
    
    <iframe name='frame_result1' width='350px' height='100px' frameborder='0'></iframe>
    <iframe name='frame_result2' width='350px' height='100px' frameborder='0'></iframe>
    
    function SubmitForm()
    {
        document.forms['theForm'].action='http://www.aaaaaa.com/1st-file.php';
        document.forms['theForm'].target='frame_result1';
        document.forms['theForm'].submit();
    
        document.forms['theForm'].action='http://www.bbbbbb.com/2nd-file.php';
        document.forms['theForm'].target='frame_result2';
        document.forms['theForm'].submit();
        return true;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器