RE: Re[2]: [PHP] Self Submitting Form

2004-02-23 Thread Sam Masiello

Ah ha!

I think I found where the problem lies(and also our confusing
disconnect).  Even though you and I were doing pretty much the same
thing, your case worked fine in the instance where the parameter being
submitted in the self submitting form was only one word.  If you changed
your test case to something like hi there (which is what I was using
in my testing), it breaks.  Why?  The parameter needs to be urlencoded
first.

Thank you very much for your help and suggestions, Toby!  I really
appreciate your time and effort in helping me to see the light.

--Sam


Toby Irmer wrote:
 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 )

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] Self Submitting Form

2004-02-21 Thread Toby Irmer
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 )

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Self Submitting Form

2004-02-20 Thread Sam Masiello

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=#FF
TEXT=#00 LINK=#00 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=myvarVALUE='+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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Self Submitting Form

2004-02-20 Thread Toby Irmer




Hi Sam,

I am not sure I know what you want to do...

I tried to recreate your problem:

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=get action=test3.html 
  INPUT TYPE=hidden NAME=do_preview VALUE=1 
script 
  document.write('INPUT TYPE=hidden NAME=itworks 
VALUE='+opener.myform1.myvar1.value+'');
/script
/FORM 
/BODY


test3.html

script language=Javascript
function parseQueryString (str) 
{
str = str ? str : location.search;
var query = str.charAt(0) == '?' ? str.substring(1) : str;
var args = new Object();
if (query) 
{
var fields = query.split('');
for (var f = 0; f  fields.length; f++) 
{
var field = fields[f].split('=');
args[unescape(field[0].replace(/\+/g, ' '))] = 
unescape(field[1].replace(/\+/g, ' '));
}
}
 return args;
}

var args = parseQueryString ();
for (var arg in args) 
{
  document.write(arg + ': ' + args[arg] + 'BR');
}
/script


And the output is:

do_preview: 1
itworks: testing


As should be expected...

Pls try to specify your problem.

toby

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Self Submitting Form

2004-02-20 Thread Sam Masiello
 
Hi Toby!
 
Thank you for your suggestion, but unfortunately you are using GET in your test2.html 
file.  I specifically stated in my initial email that due to the fact that I am using 
textareas in my original form (your test1.html) that I did not want to use GET for it 
might run the risk of overstepping the bounds of how many characters the browser will 
accept in the GET string.
 
Any other suggestions that anyone else has would be most appreciated as I am still 
pretty stuck on this.
 
As always, thanks in advance!
 
--Sam
 
 



From: Toby Irmer [mailto:[EMAIL PROTECTED]
Sent: Fri 2/20/2004 6:07 PM
To: Sam Masiello
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Self Submitting Form







Hi Sam,

I am not sure I know what you want to do...

I tried to recreate your problem:

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=get action=test3.html
  INPUT TYPE=hidden NAME=do_preview VALUE=1
script
  document.write('INPUT TYPE=hidden NAME=itworks 
VALUE='+opener.myform1.myvar1.value+'');
/script
/FORM
/BODY


test3.html

script language=Javascript
function parseQueryString (str)
{
str = str ? str : location.search;
var query = str.charAt(0) == '?' ? str.substring(1) : str;
var args = new Object();
if (query)
{
var fields = query.split('');
for (var f = 0; f  fields.length; f++)
{
var field = fields[f].split('=');
args[unescape(field[0].replace(/\+/g, ' '))] = 
unescape(field[1].replace(/\+/g, ' '));
}
}
 return args;
}

var args = parseQueryString ();
for (var arg in args)
{
  document.write(arg + ': ' + args[arg] + 'BR');
}
/script


And the output is:

do_preview: 1
itworks: testing


As should be expected...

Pls try to specify your problem.

toby





Re: [PHP] Self Submitting Form

2004-02-20 Thread Tom Rogers
Hi,

Saturday, February 21, 2004, 8:00:43 AM, you wrote:

SM My apologies if this post is somewhat OT.  I am having some trouble
SM figuring something out, and I am hoping you can help.

SM I have a PHP web form on which a user can enter a number of different
SM things
SM into both text and textarea fields.  At the bottom of the form is a
SM preview button which opens another browser window.
 
SM I know I can use the GET string to pass these form fields from one
SM PHP page to another, but with
SM textareas involved and the possibly large amounts of text being
SM passed, I didn't want to run the possibility of overrunning the limit
SM on a GET string.  So I figured using a form POST would be more
SM appropriate. 

SM My thought was to create a self submitting form in the child window, but
SM I am having
SM trouble getting it to work (or maybe I should try a different method
SM entirely to do this...any suggestion welcome!).  My code for the
SM preview window (which contains the self submitting form is as
SM follows: 

SM ?
SM if ($do_preview) {
SMecho $myvar; exit;
SM }
?
 
SM HTML
SM HEAD
SM TITLE/TITLE
SM META HTTP-EQUIV=Content-Type CONTENT=text/html; charset=iso-8859-1

SM /HEAD 
SM BODY onLoad=document.preview_form.submit() BGCOLOR=#FF
SM TEXT=#00 LINK=#00 FORM NAME=preview_form METHOD=post
SM ACTION=? echo $PHP_SELF ? 
SM   INPUT TYPE=hidden NAME=do_preview VALUE=1 
SM script 
SM   document.write('INPUT TYPE=hidden
SM NAME=myvarVALUE='+opener.myform1.myvar1.value+'');
SM /script
SM /FORM 
SM /BODY 
SM /HTML 

SM (I also tried doing an eval within the VALUE attribute, but all that did
SM was set myvar to the text that I had between the quotes :) )

SM When I click the preview button on the parent window, I would like to
SM see the value of the myvar1 variable when the form self
SM submits...unfortunately, I get nothing.  I know it is getting into my
SM $do_preview block at the top, and I am accessing the variable
SM correctly because if I do an alert(opener.myform1.myvar1.value), I
SM get the proper value. 

SM Any thoughts would be greatly appreciated!
 
SM --Sam

SM --
SM PHP General Mailing List (http://www.php.net/)
SM To unsubscribe, visit: http://www.php.net/unsub.php


You need to use sessions to store the data between pages

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php