Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PHP
<?php 
   if ($_SESSION['C'] == false) 
   {
    echo "<a href='admin/' class='logo1' title='Login' ><img src='image/login.png'>
   <span>Login</span></a>";
}

Notice: Undefined index: C in C:\xampp\htdocs\Souvenir_Mysql\souvenir_bkt\index.php on line 3913

PHP
<?php 
  if ($_SESSION['C'] == true) {
    echo $_SESSION['username']; 
  }

Notice: Undefined index: C in C:\xampp\htdocs\Souvenir_Mysql\souvenir_bkt\index.php on line 3997
Visitor !

What I have tried:

I have the new version of mysql
I thought it was because of it
Posted
Updated 14-Sep-20 22:46pm
v2

1 solution

Quote:

This error means that within your code, there is a variable or constant that has no value assigned to it. But you may be trying to use the values obtained through the user form in your PHP code.

The error can be avoided by using the isset() function. This function will check whether the index variables are assigned a value or not, before using them.

Based on the error and code lines you share, it seems the $_SESSION['C'] is not defined. i.e.: Index 'C' does not exists in the variable $_SESSION.

You have the entire code. Use DEBUGGER and step through to see the same and then find why so, handle it. If isset() helps, go ahead and use it based on the flow.

Refer:
PHP isset() Function[^]
PHP: Debugging in PHP - Manual[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900