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 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助