Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
September 13, 2011, 8:51 pm
rate this thread
i have and index.php file which i have a menu and i want to unclude
some others file in it, using some parameteres passed from the url.
But i am getting an error "Notice: Undefined index: action.... in line
Heres my code:
in another line inside the same index.php file i have:
else if ($_GET['action']=="store")
else if ($_GET['action']=="login")
echo "Welcome screen";
When i am in the home address i get an error "Notice: Undefined index:
action" for all 3 lines i use $_GET['action']. When i click on the
other links eg store or profile the include is being done
What am i doing wrong??
Thanks in advance
Re: Notice: Undefined index: action error please help
Your entire PHP script is executed and terminates before the page is
displayed on the browser. So the first time though, $_GET['action']
doesn't exist. When someone clicks on a link, then the action parameter
is passed to the script and $_GET['action'] has a value.
Any time you're expecting something from the browser you should check to
see if it has been set with isset(), i.e.
if (isset($_GET['action'])) ...
And only try to process the parameter if it has been set.
Remove the "x" from my email address
JDS Computer Training Corp.
- » What would you like to see in most in a text editor?
- — Previous thread in » PHP Scripting Forum