Re: Form data

From: Date: Mon, 08 Sep 2003 14:33:35 +0000
Subject: Re: Form data
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-161989@lists.php.net to get a copy of this message
Forget about cookies and sessions (because cookies are evil). The way I do something like this is: <?php foreach ($_POST as $key => $value) { if (!(($key == 'dont_save') OR ($key == 'dont_save_2'))) { hidden($key, $value); } } function hidden($key, $value) // saves lots of time { print "<INPUT TYPE=HIDDEN NAME='{$key}' VALUE='{$value}'>\n"; } ?> Then you can keep information from one form to the next. If you really want to get tricky add something like: <?php foreach ($key_not_to_save as $key) { hidden("dontsave[1]",$key); } // then you can call the foreach above as: foreach ($_POST as $key => $value) { if (!($_POST['dont_save[{$key}]'] )_ { hidden($key, $value); } } ?> -Dan

« previous php.general (#161989) next »