Re: undefined variable: action

From: Date: Wed, 11 Jun 2003 20:22:58 +0000
Subject: Re: undefined variable: action
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-151135@lists.php.net to get a copy of this message
On Wed, 2003-06-11 at 12:22, Ryan M wrote: > Thanks for the advice... The link worked.... Now it is saying this: > > Notice: Undefined index: action in.... > > It only says this if there is no action...it goes away once I click the link > and the action=someaction.... Is there a way to fix my php so that I dont > have to change all of the web sites hosted on my server?? Thanks! > > Ryan Check and initialize your input variables: if (!isset($_GET['action'])) { $action = ''; } else { $action = $_GET['action']; } switch ($action) { case 'something': do_something(); break; case 'something_else': do_something_else(); break; default: echo "Unrecognized action given"; break; } If this is something you need to do for every page on your site, put the if() check into an auto-prepended file or something. Hope this helps, Torben -- Torben Wilson <torben@php.net> +1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com -----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----

« previous php.general (#151135) next »