Passing variables to form processor

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mikeym
Forum Newbie
Posts: 20
Joined: Sun Dec 16, 2007 8:07 am

Passing variables to form processor

Post 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?
mikeym
Forum Newbie
Posts: 20
Joined: Sun Dec 16, 2007 8:07 am

Re: Passing variables to form processor

Post 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?
mikeym
Forum Newbie
Posts: 20
Joined: Sun Dec 16, 2007 8:07 am

Re: Passing variables to form processor

Post by mikeym »

*bump* :cry:
Post Reply