RE: [PHP] Passing variables to page via POST - How?
| From: | skeller at healthtvchannel dot org | Date: | Fri, 19 Jul 2002 16:52:40 +0000 |
| Subject: | RE: [PHP] Passing variables to page via POST - How? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108544@lists.php.net to get a copy of this message | ||
> I need to pass several variables, one that is an array and
> another that is a fairly long string, so, I can't really do
> this via the URL.
>
> My initial idea was to just create a very simple form that
> only has hidden fields with the data I want to pass, along
> with an image Submit button
First, do you know how many fields will be in the array?
Second, are you going from an HTML form to PHP or PHP to a script?
The reason I'm asking is I just did something similar to this. I had to pull
a half-dozen variables out of an LMS system with CMI calls and then pass
them to a PHP page. What I did was load a blank page, pull the variables I
needed out of the system, then javascript post them to the PHP page. It
gives a bit of a delay for the user, but it works.
(javascript.htm)
<html>
<head><title></title></head>
<body>
<form action="http://my.php.script"
method="post" name="myForm">
<input type="hidden" name="variable1">
<input type="hidden" name="variable2">
</form>
<!-- Notice there's no submit button -->
<script language="JavaScript">
loadvariables();
document.myForm.variable1.value = loadedVariable1;
document.myForm.variable2.value = loadedVariable2;
document.myForm.variable1.submit();
<!-- after loading the variables, javascript submits the form to the php -->
</script>
</body>
</html>