CSI: PHP

"Looking at your tweets I cannot even fathom what your job is. CSI:PHP?" — @grmpyprogrammer

We Don't Need No Stinkin' POST Variables

| Comments

CSI: PHP investigator Duane Gran sent in this horrifying snippet. He explains:

I wondered why dumping the $_POST variables before this section didn’t help in debugging. This occurs in a second step of a 3-step form on a GET request. It applies a set of session fields to the $_POST variable for later use.

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php

foreach($_SESSION["purchase"] as $key => $value)
{
    switch($key)
    {  
        case "process_purchase":
            break;
        default:
            $_POST[$key] = $value;
            break;
    }
}

Comments