Question:
PHP - Undefined index?
anonymous
2011-03-14 10:35:58 UTC
I just re-installed XAMPP and I'm getting an error that I've never gotten before.

Notice: Undefined index: username in C:\xampp\htdocs\acc_terminator\unicode.php on line 3

Notice: Undefined index: password in C:\xampp\htdocs\acc_terminator\unicode.php on line 4

Notice: Undefined index: account_level in C:\xampp\htdocs\acc_terminator\unicode.php on line 5

Those lines are:
$xusername = $_SESSION['username'];
$xpassword = $_SESSION['password'];
$xaccount_level = $_SESSION['account_level'];
Three answers:
David
2011-03-14 10:59:50 UTC
Comment out the lines by preceding them with a double slash. Ie:



// $xusername = $_SESSION['username'];

// $xpassword = $_SESSION['password'];

// $xaccount_level = $_SESSION['account_level'];



Or remove the 'x' from them and see what happens. That's what I would do.
?
2016-11-16 07:22:57 UTC
that's solid prepare once you assign very own homestead page variables to make advantageous they have a cost, so as that in the event that they don't have a cost you may direct human beings back to the main web site with a particular blunders message or verify if a cost has been extra. use the isset command, like this: if (isset($_POST['txtP']){ $w=$_POST['txtP']; echo $w; } else { echo "you're able to be able to desire to fill out the style."; //could be any blunders message. }
anonymous
2011-03-14 11:19:12 UTC
Write the code correctly:



$xusername = isset($_SESSION['username']) ? $_SESSION['username'] : '';

$xpassword = isset($_SESSION['password']) ? $_SESSION['password'] : '';

$xaccount_level = isset($_SESSION['account_level']) ? $_SESSION['account_level'] : '';



Evidently the code calling this page never sets those session variables.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...