Monthly Archive for December, 2023

How I Spent My Saturday — A Geeky Puzzle

I feel like I should record this, on the off-chance that it will save someone else from spending 18 hours glued to a computer screen missing the obvious. It will be of very limited interest.

Actually, let’s make it a puzzle.

So I have a php script — let’s call it A.php — which contains an html form introduced by the line < form method=POST action=”B.php” > .

There are no other calls to scripts anywhere else in A.php, and none at all in B.php.

So I enter the following in my browser’s address bar (I tried this in multiple browsers, all with the same results):

FOO/A.php?QUERYSTRING

(where of course FOO is a web address). This causes some php code to execute. That code checks to see if the query string is nonempty (which it always is at this point), and if so, it displays the form, with a submit button. Here is what happens next:

a) Roughly half the time, I hit the submit button, which calls B.php, which also executes, at which point my address bar shows FOO/B.php . This seems entirely normal.

b) The other half of the time, I hit the submit button, which causes A.php to execute a SECOND TIME (instead of calling B.php). (It now thinks the query string is empty so the form is not re-displayed.) At this point my address bar shows FOO/A.php/B.php (despite the fact that B.php was never called, or at least never executed).

There is absolutely no apparent pattern to when I get a) and when I get b). I sit at my damned screen for hours on end (this started at 6AM and ended at midnight), repeating the same input, sometimes getting a) and sometimes getting b), according to what looks to me like a series of fair coin flips.

So, because I am making **absolutely no changes** to the code, this **must** mean something is going on at the server end, right? So I move all the code to a completely different server, and get exactly the same behavior.

This is not behavior that’s easy to google for. I wasted a little time trying.

Right around midnight, the truth dawned on me.

And now I wonder: Would a programmer with the right background have been able to guess what the problem was quicker than I did? Like, maybe at least 17 hours quicker? Let’s make it a challenge.

Click here to comment or read others’ comments.

Share