Page 1 of 1

Unidentified Index

Posted: Fri Oct 21, 2011 4:31 pm
by bonbonbaron
Whenever I type anything into the search form on our company site, I get this:

Notice: Undefined index: ID in /home/blahblah/public_html/nimbus/lib/login.class.php on line 929

So I looked at the source code for the search form, and it says:

Source Code for Search Form

Code: Select all

<div class="content"><div style='display:block; width:290px; float:right;'><form name='search' method=post action='admin_options.php'><select size="1" id="area" name="area" style="float:right !important;">
[/html]

So I go to my admin_options.php file, which includes settings.php (and settings.php includes login.class.php, which is where admin_options.php draws its only two functions from). In admin_options.php, there are only 5 lines of code (I added the comment for you to know what $login is):

[i]admin_options.php[/i]
[syntax=php] <?php
	require_once ( '../settings.php' );
	$login->checkLogin ( 1 ); //$login is a new Login(), which is the class in login.class.php
	$login->process_admin_options ();	
?>
Now, the moment you were waiting for: The error is coming from the function process_admin_options (which must mean that checkLogin works just fine), used above in the five-lined admin_options.php file I just showed. Below are lines 927 through 1079 of login.class.php:

login.class.php-- Lines 927-1079, error line marked by a comment

Code: Select all

function process_admin_options ()
	{
		if ( $_GET [ 'ID' ] != '' && $_GET [ 'action' ] != '' ) //<-----Here's the error line
		{
			switch ( $_GET [ 'action' ] )
			{
				case 'suspend':
					$get_user = "SELECT ID FROM `" . DBPREFIX . "users` WHERE `ID` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_user ) == 1 )
					{
						$this->db->query ( "UPDATE `" . DBPREFIX . "users` SET `Active` = '2' WHERE `ID` = " . $this->db->qstr ( $_GET['ID'] ) );
						header ( "Location: " . APPLICATION_URL . "admin/admin.php?active=" . $_GET [ 'active' ] . "&start=" . $_GET [ 'start' ] );
					}
				break;

				case 'edit':
					$get_user = "SELECT ID FROM `" . DBPREFIX . "users` WHERE `ID` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_user ) == 1 )
					{
						header ( "Location: " . APPLICATION_URL . "admin/edit_user.php?ID=" . $_GET [ 'ID' ] );
					}
				break;
							
				case 'edit_serial':
					$get_serial = "SELECT id FROM `" . DBPREFIX . "serial` WHERE `id` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_serial ) == 1 )
					{
						header ( "Location: " . APPLICATION_URL . "admin/edit_serial.php?ID=" . $_GET [ 'ID' ] );
					}
				break;
				
				case 'edit_location':
					$get_location = "SELECT id FROM `" . DBPREFIX . "locs` WHERE `id` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_location ) == 1 )
					{
						header ( "Location: " . APPLICATION_URL . "admin/edit_location.php?ID=" . $_GET [ 'ID' ] );
					}
				break;
				
				case 'edit_test':  /////////////////////////////////************
					$get_ = "SELECT id FROM `" . DBPREFIX . "locs` WHERE `id` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_location ) == 1 )
					{
						header ( "Location: " . APPLICATION_URL . "admin/edit_location.php?ID=" . $_GET [ 'ID' ] );
					}
				break;
				

				case 'delete':
					$get_user = "SELECT ID FROM `" . DBPREFIX . "users` WHERE `ID` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_user ) == 1 )
					{
						$this->db->query ( "DELETE FROM `" . DBPREFIX . "users` WHERE `ID` = " . $this->db->qstr ( $_GET['ID'] ) );
						header ( "Location: " . APPLICATION_URL . "admin/admin.php?active=" . $_GET [ 'active' ] . "&start=" . $_GET [ 'start' ] );
					}
				break;
				
				case 'delete_serial':
					$get_serial = "SELECT id FROM `" . DBPREFIX . "serial` WHERE `id` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_serial ) == 1 )
					{
						$this->db->query ( "DELETE FROM `" . DBPREFIX . "serial` WHERE `id` = " . $this->db->qstr ( $_GET['ID'] ) );
						header ( "Location: " . APPLICATION_URL . "admin/admin_serials.php" );
					}
				break;
				
				case 'delete_test':
						$get_test = "SELECT id FROM `" . DBPREFIX . "recert` WHERE `testid` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_test ) == 1 )
					{
						$this->db->query ( "DELETE FROM `" . DBPREFIX . "tg1` WHERE `testid` = " . $this->db->qstr ( $_GET['ID'] ) );
						$this->db->query ( "DELETE FROM `" . DBPREFIX . "recert` WHERE `testid` = " . $this->db->qstr ( $_GET['ID'] ) );
						$this->db->query ( "DELETE FROM `" . DBPREFIX . "utt` WHERE `testid` = " . $this->db->qstr ( $_GET['ID'] ) );
						
						header ( "Location: " . APPLICATION_URL . "admin/admin_serials.php" );
					}
				break;

				case 'delete_location':
					$get_loc = "SELECT id FROM `" . DBPREFIX . "locs` WHERE `id` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_loc ) == 1 )
					{
						$this->db->query ( "DELETE FROM `" . DBPREFIX . "locs` WHERE `id` = " . $this->db->qstr ( $_GET['ID'] ) );
						header ( "Location: " . APPLICATION_URL . "admin/admin_locations.php" );
					}
				break;
				

				case 'activate':
					$get_user = "SELECT ID FROM `" . DBPREFIX . "users` WHERE `ID` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_user ) == 1 )
					{
						$this->db->query ( "UPDATE `" . DBPREFIX . "users` SET `Active` = '1' WHERE `ID` = " . $this->db->qstr ( $_GET['ID'] ) );
						header ( "Location: " . APPLICATION_URL . "admin/admin.php?active=" . $_GET [ 'active' ] . "&start=" . $_GET [ 'start' ] );
					}
				break;
				
				case 'deactivate':
					$get_user = "SELECT ID FROM `" . DBPREFIX . "users` WHERE `ID` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_user ) == 1 )
					{
						$this->db->query ( "UPDATE `" . DBPREFIX . "users` SET `Active` = '0' WHERE `ID` = " . $this->db->qstr ( $_GET['ID'] ) );
						header ( "Location: " . APPLICATION_URL . "admin/admin.php?active=" . $_GET [ 'active' ] . "&start=" . $_GET [ 'start' ] );
					}
				break;

				case 'delete_group':
					$get_group = "SELECT ID FROM `" . DBPREFIX . "groups` WHERE `ID` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_group ) == 1 )
					{
						//delete group members
						$this->db->query ( "DELETE FROM `" . DBPREFIX . "users` WHERE `Level_access` = " . $this->db->qstr ( $_GET['ID'] ) );
						//delete group
						$this->db->query ( "DELETE FROM `" . DBPREFIX . "groups` WHERE `ID` = " . $this->db->qstr ( $_GET [ 'ID' ] ) );
						header ( "Location: " . APPLICATION_URL . "admin/admin_groups.php?start=" . $_GET [ 'start' ] );
					}
				break;

				case 'edit_group':
					$get_group = "SELECT ID FROM `" . DBPREFIX . "groups` WHERE `ID` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_group ) == 1 )
					{
						header ( "Location: " . APPLICATION_URL . "admin/edit_group.php?ID=" . $_GET [ 'ID' ] );
					}
				break;
				
				case 'delete_customer':
					$get_customer = "SELECT ID FROM `" . DBPREFIX . "cstmr` WHERE `ID` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_customer ) == 1 )
					{
						$this->db->query ( "DELETE FROM `" . DBPREFIX . "cstmr` WHERE `ID` = " . $this->db->qstr ( $_GET [ 'ID' ] ) );
						header ( "Location: " . APPLICATION_URL . "admin/admin_customer.php" );
					}
				break;
				
				case 'edit_customer':
					$get_customer = "SELECT ID FROM `" . DBPREFIX . "cstmr` WHERE `ID` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $this->db->RecordCount ( $get_customer ) == 1 )
					{
						header ( "Location: " . APPLICATION_URL . "admin/edit_customer.php?ID=" . $_GET [ 'ID' ] );
					}
				break;
					
				case 'manage_test':
					$get_tests = "SELECT ID, serial FROM `" . DBPREFIX . "recert` WHERE `serial` = " . $this->db->qstr ( $_GET [ 'ID' ] );
					if ( $get_tests  )
					{
						header ( "Location: " . APPLICATION_URL . "admin/admin_test.php?ID=" . $_GET [ 'ID' ] . "&CSTID=" . $_GET['CSTID'] );
					}
				break;
			}
		}
	}
Could it be that I need to add 'ID' and 'action' somewhere in admin_options.php? It seems like all kinds of issues can cause the "unidentified index" error, like, for example, using $_GET for a form of method=$_POST.

Re: Unidentified Index

Posted: Fri Oct 21, 2011 5:12 pm
by Celauran
First of all, this isn't an error. It's a notice that tells you you're trying to use a variable that may not have been set.

Code: Select all

if ((isset($_GET['id']) && $_GET['id'] != '') && (isset($_GET['action']) && $_GET['action'] != ''))