Re: Variable Problem when UPGRADING...

From: Date: Tue, 30 Jan 2001 08:30:07 +0000
Subject: Re: Variable Problem when UPGRADING...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-37258@lists.php.net to get a copy of this message
James Smith wrote: > > Alright, when i was programming with PHP3, I would use > if statements like this: > > if(!$submit) { > // display form > } else { > // display signup complete > } > > to make multiple pages. Or I would do this: > > if($action == "signup") { > if(!$submit) { > //display form > } else { > // display signup complete > } > } > if($action == "login") { > // show login screen > } > > But now I get an error like this: > > Warning: Undefined variable: submit in > c:\apache\htdocs\test.php on line 3 > > I don't know if I misconfigured my php.ini file or > what. > Very likely you used the optimized version of php.ini which has global variables registration off. As for your question, I can tell you my tip: I use <input type="submit" name="action[login]" value="Login"> <input type="submit" name="action[signup]" value="SignUp"> and in the form do: $PV = $HTTP_POST_VARS; $action = isset ($PV['action']) ? key($PV['action']) : '<default-action-here>'; switch ($action) { // allows lots of action w/o too many ifs and such case 'login': // login break; case 'signup': // signup break; case 'default-action': default: // evetually break; } so on. hope it helps ciao -- teodor

« previous php.general (#37258) next »