-1

the message is

Notice: Undefined index: flag in C:\xampp\htdocs\myfiles\mobile tracking\index.php on line 63

my code is

<?php 
   $stat=$_REQUEST['flag'];
   if($stat=="FAILED")
       {
      echo "Username/password doesnot exists";
   }
?>
Bernhard Hofmann
  • 10,321
  • 12
  • 59
  • 78
  • Have a look at http://www.php.net/manual/en/reserved.variables.request.php – Reger Feb 06 '14 at 15:55
  • `Line 63`, ok let's do the math here: `63-7=56` - guess what's missing? You guessed it: **56** lines of code. Not to mention your form and/or method used. This one's the ever-classic "Can of Worms" question. You need to show us full code, or forever hold your peace, *as it were*. – Funk Forty Niner Feb 06 '14 at 16:03
  • > on line 63 No one can help you, cause this isn not your full code. Post index.php and we can take a look at it. – battleck Feb 06 '14 at 15:52

3 Answers3

1

The global variable $_REQUEST['flag'] is probably having value NULL. This is the reason you are getting this error. Well, try using isset(). to check whether the variable is having any value or not.

Nishant Ghodke
  • 923
  • 1
  • 12
  • 21
0

You should check if the $_REQUEST['flag'] variable has been set:

<?php 
$stat= ( isset($_REQUEST['flag']) ? $_REQUEST['flag'] : null) ;
if($stat=="FAILED")
{
    echo "Username/password doesnot exists";
}

?>
vanMartijn
  • 172
  • 5
0

You received a notice because you didn't initialized the values of the array. Use this construction to prevent them.

if (! array_key_exists('flag', $_REQUEST)) {
    $_REQUEST['flag'] = whatever value goes here;
}