Page 1 of 1

Passing variables to form processor

Posted: Fri May 02, 2008 5:50 am
by mikeym
Hi,

I'm trying to create a class that will manage creating forms and processing it. The problem I'm having is that I want to be able to pass the internal data of my class from the page where the form is created to the processing page. Is there any way to do this that wont cause a problem when 2 copies of the page are open?

Re: Passing variables to form processor

Posted: Fri May 02, 2008 7:11 am
by mikeym
The only way I can possibly think to do this is to create a random number when the form is created:

$myrandomno = (rand()%999999);


set an array of the parameters to the value of session with a key $myrandomno

$_SESSION["$myrandomno"]=array("internaldata1" => $_data1, "internaldata2" => $_data2);

set the value of a hidden input box to hold the key

echo "<input type=\"hidden\" name=\"key\" value=\"$myrandomno\" />";

Initialise with the values stored in the array stored in session using "key"

function FormManager() {
if(isset($_POST["key"]) {
$key=$_POST["key"];
$parameters=$_SESSION["$key"];
$_data1=$parameters["internaldata1"];
$_data2=$parameters["internaldata2"];
}


Now I know there has to be a better way than this!!

So come on what's the standard way of doing this kind of thing?

Re: Passing variables to form processor

Posted: Sat May 03, 2008 2:11 am
by mikeym
*bump* :cry: