doutuo7609 2014-08-25 05: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 05: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条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部