Re[2]: [PHP] Self Submitting Form
| From: | Toby Irmer | Date: | Sat, 21 Feb 2004 09:30:26 +0000 |
| Subject: | Re[2]: [PHP] Self Submitting Form | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-178434@lists.php.net to get a copy of this message | ||
Hi Sam,
I did that only because I was too lazy to upload and did the testing
locally so I could grab the value in Javascript.
Of course it works with post as well...
test.html
<form name="myform1" method="get" action="">
<input type="hidden" name="myvar1" value="testing">
<script>
window.open("test2.html", "test");
</script>
</form>
test2.html
<BODY onLoad="document.forms[0].submit();">
<form name="myform1" method="post" action="test.php">
<INPUT TYPE="hidden" NAME="do_preview" VALUE="1">
<script>
document.write('<INPUT TYPE="hidden" NAME="itworks"
VALUE="'+opener.myform1.myvar1.value+'">');
</script>
</FORM>
</BODY>
test.php
<?
print_r($_POST);
?>
Outputs:
Array ( [do_preview] => 1 [itworks] => testing )