Undefined index 'myusername'
<p>My update php coding is not working.</p>

<blockquote>
  <p>Notice: Undefined index: myusername in line 286 Notice: Undefined index:mypassword line 287</p>
</blockquote>

<p><strong>con_login.html:</strong></p>

<pre><code>//html page
//to create login table 
&lt;form name="form1" method="post" action="con_login.php" onSubmit="return check()";&gt;
&lt;td&gt;
&lt;table width="110%" height="99" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"&gt;
&lt;tr&gt;
&lt;td colspan="3"&gt;&lt;strong&gt;Member Login &lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width="78"&gt;Email-id&lt;/td&gt;
&lt;td width="6"&gt;:&lt;/td&gt;
&lt;td width="294"&gt;&lt;input name="myusername" type="text" id="myusername"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Password&lt;/td&gt;
&lt;td&gt;:&lt;/td&gt;
&lt;td&gt;&lt;input name="mypassword" type="password" id="mypassword"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;input type="submit" name="Submit" value="Login"&gt;&lt;/td&gt;
&lt;/tr&gt;
**con_login.php:**//php page
//form action when click an button
 &lt;form name="form1" method="post" action="" onSubmit="return check();"&gt;
&lt;?php
session_start();
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("shg", $con);
$result = mysql_query("SELECT * FROM consumer");
$email=$_POST['myusername'];
$password=$_POST['mypassword'];
$query="select * from consumer where email='$email' and password='$password'";
$result=mysql_query($query);
if(!mysql_num_rows($result)==1)
{
echo("  &lt;script&gt;   alert('INVALID USER / PASSWORD - PRESS (OK) TO LOGIN PAGE');      &lt;/script&gt; ");
 echo ("&lt;script&gt;     window.location = 'con_login.html';     &lt;/script&gt;"); 
}          
else
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
 // Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
}
echo ("&lt;script&gt; alert('welcome');    &lt;/script&gt;");
$query="select * from consumer where email='$_POST[myusername]'";
echo "&lt;h2&gt;&lt;center&gt;welcome&lt;/center&gt;&lt;/h2&gt;";
echo "&lt;table border='7'   cellspacing='10' cellpadding='10'&gt;
&lt;tr&gt;
&lt;th&gt;title&lt;/th&gt;
&lt;th&gt;Firstname&lt;/th&gt;
&lt;th&gt;Lastname&lt;/th&gt;
&lt;th&gt;title&lt;/th&gt;
&lt;th&gt;organisation&lt;/th&gt;
&lt;th&gt;address1&lt;/th&gt;
&lt;th&gt;address2&lt;/th&gt;
&lt;th&gt;city&lt;/th&gt;
&lt;th&gt;state&lt;/th&gt;
&lt;th&gt;zip&lt;/th&gt;
&lt;th&gt;country&lt;/th&gt;
&lt;th&gt;Fax&lt;/th&gt;
&lt;th&gt;Mail&lt;/th&gt;
&lt;/tr&gt;";
while($row = mysql_fetch_array($result))
  {
  echo "&lt;tr&gt;";
  echo "&lt;td&gt;" . $row['title'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['firstname'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['lastname'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['title1'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['organisation'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['address1'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['address2'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['city'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['state'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['zip'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['country'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['fax'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['email'] . "&lt;/td&gt;";
  echo "&lt;/tr&gt;";
  }
echo "&lt;/table&gt;";

$query="select * from consumer where email='$_POST[myusername]'";
  $res = @mysql_query($query);
  while($row = mysql_fetch_array($res))
   {
echo "&lt;TABLE BORDER='0' ALIGN='CENTER' WIDTH='95%'&gt;";
echo"&lt;h2&gt;Consumer Registration&lt;/h2&gt;";
echo"&lt;h3&gt;&lt;b&gt;";
echo"&lt;tr&gt;";
echo"&lt;td&gt;Title&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='t1' value=\"$row[title]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
echo"&lt;tr&gt;";
echo"&lt;td&gt;Firstname&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='n1' value=\"$row[firstname]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
 echo"&lt;tr&gt;";
echo"&lt;td&gt;Lastname&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='n2' value=\"$row[lastname]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
echo"&lt;tr&gt;";
echo"&lt;td&gt;Password&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='p1' value=\"$row[password]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
 echo"&lt;tr&gt;";
echo"&lt;td&gt;Confirm Password&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='p2' value=\"$row[confirmpassword]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
 echo"&lt;tr&gt;";
echo"&lt;td&gt;Title&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='n3' value=\"$row[title1]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
 echo"&lt;tr&gt;";
echo"&lt;td&gt;Organisation&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='n4' value=\"$row[organisation]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
 echo"&lt;tr&gt;";
echo"&lt;td&gt;Address1&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='n5'  value=\"$row[address1]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
echo"&lt;tr&gt;";
echo"&lt;td&gt;Address2&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='n6' value=\"$row[address2]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
 echo"&lt;tr&gt;";
echo"&lt;td&gt;City&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='n7' value=\"$row[city]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
echo"&lt;td&gt;State&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='s1' value=\"$row[state]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
echo"&lt;td&gt;Zip&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='z1' value=\"$row[zip]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
echo"&lt;td&gt;Country&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='c1' value=\"$row[country]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
 echo"&lt;td&gt;Fax&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='fa1' value=\"$row[fax]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
echo"&lt;td&gt;E-mail&lt;/td&gt;";
echo"&lt;td&gt;";
printf("&lt;input type='text' name='e1' value=\"$row[email]\"&gt;\n");
echo"&lt;/td&gt;&lt;/tr&gt;";
  }
mysql_close($con);
?&gt;

&lt;?php
//including the database connection file

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("shg", $con);
//declare variables
$result = mysql_query("SELECT * FROM consumer");
if(isset($_POST['update']))
{
    $title= $_POST['t1'];

    $firstname=$_POST['n1'];
    $lastname=$_POST['n2'];
    $password=$_POST['p1']; 
    $confirmpassword=$_POST['p2'];
    $title1=$_POST['n3'];
    $organisation=$_POST['n4'];
    $address1=$_POST['n5'];
    $address2=$_POST['n6']; 
    $city=$_POST['n7'];
    $state=$_POST['s1'];
    $zip=$_POST['z1'];
    $country=$_POST['c1'];
    $fax=$_POST['fa1'];
    $email=$_POST['e1'];
//update query
   $result="update consumer set title='$t1',firstname='$n1',lastname='$n2',password='$p1',confirmpassword='$p2',title1='$n3',organisation='$n4',address1='$n5',address2='$n6',city='$n7',state='$s1',zip='$z1',country='$c1',fax='$fa1',email='$e1'";
    }
    mysql_close($con);
?&gt;
//update button
&lt;body&gt;
&lt;input type="submit" name="update" value="update" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/body&gt;
</code></pre>
