A small problem that has me kinda baffled. This is the situation:
I've set up a self-submitting form FORM.PHP. Once the inputs are
validated, the info gets put in SESSION variables and the script
redirects the user to a review form REVIEW.PHP which displays the info
the user has input and allows them to edit or submit. At the top of
that page, I have the following code:
--- start code ---
foreach ($_SESSION as $key=>$submission) {
if ( empty($submission) || ($submission == "") || (strlen($submission)
== 0) ) {
$DISPLAY[$key] = "« BLANK »";
}
else {
$DISPLAY[$key] = $submission;
}
}
extract($DISPLAY);
--- end code ---
The form then displays the info now extracted from the $DISPLAY array.
By creating a new array $DISPLAY for the $_SESSION variables, the idea
is that this page will indicate the optional fields where the user
didn't input data with the string, "BLANK", without changing data in
the $_SESSION array. At the bottom, there is an edit button which will
take a user back to the original form where the form will be
repopulated with the $_SESSION data.
The problem I'm having is that the blank $_SESSION variables are being
overwritten with the "BLANK" string that's only meant to appear in the
review form. Not a huge problem, but I can't figure out why it is
happening.
Any ideas? I've scoured my code. There's nothing that deliberately
overwrites info in the $_SESSION array on the review page. All I can
figure is it must have something to do with the way FOREACH operates.
Any help is appreciated,
Tom