Getting Notice: Undefined index:

Hi

I am getting following notices in the following php code

Notice: Undefined index: who in C:\websites\return_submission\index.php on line 188

Notice: Undefined index: who in C:\websites\return_submission\index.php on line 192
[php]

<?php session_start(); ob_start(); include 'connection.php'; ?> Untitled Document <?php $sql="SELECT * FROM company"; $res=mysql_query($sql); ?>
<?php include 'header.php';?>
Online Return Form Submission System
<?php include 'left.php';?>

All fields marked with * are mandatory

<?php if(isset($_SESSION['msg'])) { ?> <?php } ?> <?php if($_POST['who'] == 'jute_commissioner') { login1(); } elseif($_POST['who'] == 'Others') { login2(); } ?>
<?php echo $_SESSION['msg']; unset ($_SESSION['msg']); ?>
User Login
Jute Commissioner   Others
Select your State * : Select state Assam Andhra Pradesh Tripura Uttar Pradesh West Bengal
Company : <!--
		  </select>---><div id="outputcompany"></div></td>
        </tr>
        <tr> 
          <td>Factory</td>
          <td><strong><font size="+2">:</font></strong></td>
          <td colspan="2"  id=""><!--<select name="Factory" id="outputfactory"  >
		  <option>select</option>
		  </select>---><div id="outputfactory"></div></td>
        </tr>
        <tr> 
          <td>User Name <span class="style1">* </span></td>
          <td><font size="+2"><strong>:</strong></font></td>
          <td colspan="2"><input type="text" name="user_name"></td>
        </tr>
        <tr> 
          <td>Password <span class="style1">*</span> </td>
          <td><strong><font size="+2">:</font></strong></td>
          <td colspan="2"><input name="pwd" type="password" size="30" maxlength="20"></td>
        </tr>
        <tr> 
          <td height="32" colspan="3"> <div align="right"> 
              <input type="submit" name="Submit" value="Submit" onClick="return valid();">
            </div></td>
          <td width="64%" height="32"><input type="reset" name="Submit2" value="Reset" align="left"></td>
        </tr>
      </table>
    </form>
  </div></td>
<?php include 'bottom.htm';?>
<?php function login1() { $user_name=trim($_REQUEST['user_name']); $pwd=trim($_REQUEST['pwd']); $sql2 = "SELECT * FROM jute_comm WHERE jc_username='$user_name' and jc_pwd='$pwd'"; $res2 = mysql_query($sql2);
if(mysql_num_rows($res2) > 0)
{
	$row2 = mysql_fetch_array($res2);
	$_SESSION['USERID'] = $row2['id'];
	header("location:login_jute.php");
}
else
{
	$_SESSION['msg'] = "Wrong username or password.";
	header("location:index.php");
}

}
function login2()
{
$user_name=trim($_REQUEST[‘user_name’]);
$pwd=trim($_REQUEST[‘pwd’]);
$company=$_REQUEST[‘company’];
$sql3 = “SELECT * FROM factory WHERE fac_username=(’$user_name’) and fac_pwd=(’$pwd’)”;
$res3 = mysql_query($sql3);
if(mysql_num_rows($res3) > 0)
{
$row3 = mysql_fetch_array($res3);
$_SESSION[‘USERID’] = $row3[‘com_id’];
if($_SESSION[‘USERID’]==$company)
header(“location:login_mill.php”);
else
echo"Invalid User id or Password with respect to company";
}
else
{
$_SESSION[‘msg’] = “Wrong username or password.”;
header(“location:index.php”);
}
}
?>

[/php]

Can anybody let me know where I am doing mistake?

Thanks in advance.

Prasun

And, which line is 188 and 192???

It seems that the problem is with the lines:

[php]

<?php if($_POST['who'] == 'jute_commissioner') { login1(); } elseif($_POST['who'] == 'Others') { login2(); } ?>

[/php]

Not sure, your code looks fine. But, in PHP, usually you define your functions before you use them.
So, perhaps just moving the functions to the top of the page might fix this.

In Javascript it does not matter where you put your functions, but, PHP seems to like them defined before using them. Try that and let us know…

Sponsor our Newsletter | Privacy Policy | Terms of Service