1
blyfoten
wierd code?
  • 2004/11/1 8:35

  • blyfoten

  • Just popping in

  • Posts: 3

  • Since: 2004/10/29


in register.php i find this code on line 118 and 122, a switch() statement on an variable that's set just a couple of rows earlier??
le="color: #000000"><?php $op = 'register'; //row 118 foreach ( $_POST as $k => $v ) { $$k = $v; } switch ( $op ) { //row 122 case 'newuser': . . /*helluvalot of code thats never going to be executed?!*/ . . case 'finish': . . /* even more useless code */ . . /* and finaly */ case 'register': default: include 'header.php'; //OpenTable(); include 'include/registerform.php'; $reg_form->display(); //CloseTable(); include 'footer.php'; break; }


2
blyfoten
Re:wierd code?
  • 2004/11/1 8:40

  • blyfoten

  • Just popping in

  • Posts: 3

  • Since: 2004/10/29


oops sorry for my doublepost

3
ackbarr
Re:wierd code?

and you are questioning the need for such code?

$op is a variable used to control which action (or operation) the page is currently handling.
le="color: #000000"><?php $op = 'register'; //row 118

This line sets the default value for $op (in case the page is requested without an $op variable set.

le="color: #000000"><?php foreach ( $_POST as $k => $v ) { $$k = $v; }


This section retrives every variable submitted in the POST page request and creates a local variable for it. 'op' can be (and usually is) defined in the POST request and if it is, its value is assigned to the local variable $op. Now $op variable is looked at, and the proper requested action is run.

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits