开发者

Open new page with post data

In PHP, i want to open more that one window and each one of them need to recieve different post data.

i know how to redirect a page via header location + Get DATA, but i really need 开发者_运维知识库to be able to send POST data.

EDIT:

Graph
       |-Page with post 1
Main --|-Page with post 2
       |-Page with post 3

so basically 1 page goes and open 3 pages with different post data on each. must be done server Side.


why not use three forms? ;-) Code tested, works.

<form method='post' action='http://<sever>/post1.php' id='action_frm1' name="action_frm1" target="_blank">
  <input type='hidden' name='param1' value='hello'/>
  <input type='hidden' name='param2' value='world'/>
</form>
<form method='post' action='http://<sever>/post2.php' id='action_frm2'  name="action_frm2" target="_blank">
  <input type='hidden' name='param1' value='hello2'/>
  <input type='hidden' name='param2' value='world2'/>
</form>
<form method='post' action='http://<sever>/post3.php' id='action_frm3'  name="action_frm3" target="_blank">
  <input type='hidden' name='param1' value='hello3'/>
  <input type='hidden' name='param2' value='world3'/>
</form>
<script type='text/javascript'>
     function makePostRedirect() {
       document.getElementById('action_frm1').submit();
       document.getElementById('action_frm2').submit();
       document.getElementById('action_frm3').submit();
     }
     makePostRedirect()
</script>

Of course, if you want post data via serverside usefull link will be this: http://noobflash.com/server-side-post-with-php/


you may use the following trick:

<form method='post' action='action.php' id='action_frm'>
  <input type='hidden' name='param1' value='hello'/>
  <input type='hidden' name='param2' value='world'/>
</form>
<script type='text/javascript'>
     function makePostRedirect() {
       document.getElementById('action_frm').submit();
     }
</script>


You will need to do a workaround by calling window.open to some stub PHP pages that can then use some JavaScript to call a form post. What your asking can not really be done in PHP because PHP is server side and not front end. Your looking for a much more JavaScript reliant solution.


You can do a single POST to a new window by putting a target="_new" on the <form> element. It won't validate, but it will open ONE new window and submit the form data via that window.

For multiple windows, you'll have to hack together some JS to open the multiple windows, insert a form with a copy of the data you want to have posted in that window, then trigger the posts individually.


how about this:

Original page ---opens---> page 1 ---opens---> page 2 ---opens---> page 3

Each page passes the data for the remaining pages. Search for javascript pop-up code that works and runs on page open.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜