Page 1 of 1

Passint variables through POST

Posted: Thu Dec 25, 2003 3:28 am
by ptysell
i was wondering if it is possible to pass a variable through POST. I need to pass an array to another document through post. I know that it is not possible to call PHP function through a button. I just want to cut down on the number of queries that i perform.

What i am trying to do is to creat a function that takes the page content and opens it in a new window w/o page nav so that it prints nice.

I could pass the artical ID to the other page, but that would require another MYSQL query. I can pass the text of the document through POST.

I am not sure what is better.

Thanks.

Hope that makes since but it is late and i am too lazy to re read it.

Posted: Thu Dec 25, 2003 5:05 am
by amarquis
Not sure to get what you need but you could try the following as this is the method I use to pass variables from a page to another :

On your page1.php :

Code: Select all

<FORM ACTION="page2.php" METHOD="post" ENCTYPE="x-www-form-urlencoded">
<input type="text" name="FIELD1">
<input type="submit" name="SUBMIT" value="Next">
</FORM>
On page2.php :

Code: Select all

<?php
echo "$FIELD1";
?>
Hope this helps...

Posted: Thu Dec 25, 2003 6:41 am
by dsoftnet
I want to know where is your contant stored that you want to pass out.

is that in DB or just static text?

Posted: Thu Dec 25, 2003 7:24 am
by gite_ashish
u can keep the db field(s) contents in some hidden variable(s) in the main window and open the new window (w/o nav), and access the hidden vars in JavaScript like:
window.opener. formName.varName.value

in this case, no post required, and u r saving the query also.

Posted: Fri Dec 26, 2003 12:33 am
by ptysell
i got it under controll but thanks.
I am just passing each variable that i need through post and then just outputting it in a new window via the target = _blank.

Thanks.