Self Submitting Form

From: Date: Fri, 20 Feb 2004 22:00:43 +0000
Subject: Self Submitting Form
Groups: php.general 
Request: Send a blank email to php-general+get-178401@lists.php.net to get a copy of this message
My apologies if this post is somewhat OT. I am having some trouble figuring something out, and I am hoping you can help. I have a PHP web form on which a user can enter a number of different things into both text and textarea fields. At the bottom of the form is a preview button which opens another browser window. I know I can use the GET string to pass these form fields from one PHP page to another, but with textareas involved and the possibly large amounts of text being passed, I didn't want to run the possibility of overrunning the limit on a GET string. So I figured using a form POST would be more appropriate. My thought was to create a self submitting form in the child window, but I am having trouble getting it to work (or maybe I should try a different method entirely to do this...any suggestion welcome!). My code for the preview window (which contains the self submitting form is as follows: <? if ($do_preview) { echo $myvar; exit; } ?> <HTML> <HEAD> <TITLE></TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> </HEAD> <BODY onLoad="document.preview_form.submit()" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#000000"> <FORM NAME="preview_form" METHOD="post" ACTION="<? echo $PHP_SELF ?>"> <INPUT TYPE="hidden" NAME="do_preview" VALUE="1"> <script> document.write('<INPUT TYPE="hidden" NAME="myvar"VALUE="'+opener.myform1.myvar1.value+'">'); </script> </FORM> </BODY> </HTML> (I also tried doing an eval within the VALUE attribute, but all that did was set myvar to the text that I had between the quotes :) ) When I click the preview button on the parent window, I would like to see the value of the myvar1 variable when the form self submits...unfortunately, I get nothing. I know it is getting into my $do_preview block at the top, and I am accessing the variable correctly because if I do an alert(opener.myform1.myvar1.value), I get the proper value. Any thoughts would be greatly appreciated! --Sam

« previous php.general (#178401) next »