note 18019 deleted from function.session-register by sniper
| From: | sniper@php.net | Date: | Thu, 31 Oct 2002 00:45:38 +0000 |
| Subject: | note 18019 deleted from function.session-register by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-38780@lists.php.net to get a copy of this message | ||
if you are processing a form within a session (which is easiest when there are several form levels
before inserting into a DB) you will need to do this extra step to add the new posted variables:
if(isset($HTTP_POST_VARS[formvars])){
//necessary when using session_register() because session vars take precedence
foreach($HTTP_POST_VARS[formvars] as $key => $val){
$formvars[$key] = $val;
}
}
...where $formvars is an array of all your form variables.
**warning: read the security section of the manual first (session, or 'server', vars take
precedence for a reason)**
as another comment stated, you should call session_register("formvars") after any work has
been done on the variables so that the latest changes get saved to the session.
the above loop will keep most of your variable values updated by the form but you also have to watch
out for checkboxes. Checkbox variables are only created if they are checked so you will need to
unset() them when they are not checked:
if(!isset($HTTP_POST_VARS[formvars][a_checkbox])){
unset($formvars[a_checkbox]);
}