-1

So when I am not logged in to my site via steam it shows this error ( Notice: Undefined index: steamid in C:\xampp\htdocs\index.php on line 468) but when I log in via steam it is gone.

CODE:

  <?php if(isadmin($_SESSION['steamid'])){
  echo'Admin tools: [<a href="chatadm.php?do=clear" onclick="return popitup(\'chatadm.php?do=clear\');">clear chat</a>], [<a href="chatadm.php?do=toggle" onclick="return popitup(\'chatadm.php?do=toggle\');">turn '.(chaton() ? 'off' : 'on').'</a>]';
} ?>

Line 468 is this line:

<?php if(isadmin($_SESSION['steamid'])){

Hope someone can help. Thanks.

Zybux
  • 1
  • 2

2 Answers2

0

Check if array index is set like below

<?php if( isset($_SESSION['steamid']) && isadmin($_SESSION['steamid'])) {
Gokul Shinde
  • 957
  • 3
  • 10
  • 30
0

You are getting this error because 'steamid' is not set to the session array.

You need to check also if it is set.

try something like:

<?php if(isset($_SESSION['steamid']) && isadmin($_SESSION['steamid'])){

isset — Determine if a variable is set and is not NULL

http://php.net/manual/en/function.isset.php

St0iK
  • 628
  • 3
  • 10