XAMPP Undefined Index - $_SESSION, $_POST, $_GET, $_REQUEST

Problems with the Windows version of XAMPP, questions, comments, and anything related.

XAMPP Undefined Index - $_SESSION, $_POST, $_GET, $_REQUEST

Postby yodrica » 29. January 2012 01:36

Hello all, this is my second time installing XAMPP onto my Windows XP OS, and I didn't have this problem before.

I'm trying to make a Google Chrome tab to make users' experiences with Chrome more personalized.

I just started it, and so I decided to start functions.php:

Code: Select all

Here is the error that I am getting:
Notice: Use of undefined constant username - assumed 'username' in C:\xampp\htdocs\chrome\functions.php on line 2

I've searched around, and have found no answers. Again, I did not have this problem with XAMPP before, at least, I don't think I did.

I tried configuring php.ini and set error reporting to just E_ALL just to see if PHP would "shut up". No luck.

Could you please help me understand why things such as $_SESSION, $_COOKIE, $_GET, $_POST, $_SERVER, and $_REQUEST are not working and why they are thought to be undefined indexes?

Thank you. Your answers are appreciated.
Posts: 1
Joined: 29. January 2012 01:29
Operating System: Windows XP

Re: XAMPP Undefined Index - $_SESSION, $_POST, $_GET, $_REQU

Postby Altrea » 29. January 2012 09:51

Hi Ricky,

  1. Your sourcecode doesn't fit to any of the two error messages
  2. I don't believe you didn't find anything about that two error messages. They are very common.

To prevent undefined index messages, proof your array keys with isset() or empty() before you use them. You have done this in your posted code.
Code: Select all
$key = $_SESSION['key'];

if( isset( $_SESSION['key'] ) ) {
    $key = $_SESSION['key'];

To prevent Use of undefined constant messages, put your array keys into single or double quotes. You have done that too in your posted sourcecode.
Code: Select all
echo $_SESSION[key];

echo $_SESSION['key'];

So, nothing more to do.

best wishes,
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
AF Moderator
Posts: 11953
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 111 guests