recent posts

Why They Say RTFM

Taking It to the Street

One Foot on a Stone

I just swallowed something in my coffee.

Craziest Thing You Did at Disneyland

SBC Call Annoyance Bureau, Heal Thyself

The Perfect Hot Buttered Rum

Shit, 2005!

Two Headlines from Todays New York Times

The New Office Craze

archives

Friday, January 14, 2005
Fucking Nerds
So I ask a pretty simple question in a PHP forum:
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.


And this is the first response:


I don't know, why you have to mess up with session for form. Here is
my old version of form processing script <
http://groups.google.com/groups?as_umsgid=abc4d8b8.0402130547.2f09d.....>,
which may be helpful sometimes.

--
<?php echo 'Just another PHP saint'; ?>


Just another tactless PHP dork is more like it. The link he included didn't even work. All I can say is, what an asshole. Had to say it here to avoid a flame war.
Anonymous Anonymous comments:
Google groups did mung the link. Check http://groups.google.com/group/comp.lang.php/msg/0e2993a82146ad31