title: disabled textbox causes errors in PHP page when trying to update table in mysql
body: <p>I'm caught in a set of twisting codes. I've a table in a form which consists of all the information from one table say emp_info. I am not including all the mysql query and db connection but just suppose this table has fetched information from emp_info table from my database. Example:</p>
  
  <pre><code>&lt;table align="center"&gt;
  &lt;form name="f1" action="update.php" method="post"&gt;
      &lt;tr&gt;
         &lt;td&gt;Enter name : &lt;/td&gt;&lt;td&gt;&lt;input type="text"  name="ename" id="field1" 
            disabled="disabled"  /&gt;&lt;/td&gt;&lt;td&gt;&lt;input id="myCheckBox1" type="checkbox"
              onclick="enableText1(this.checked, 'field1');" /&gt;
         &lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
        &lt;td&gt;Enter Address : &lt;/td&gt;&lt;td&gt;&lt;input type="text"  name="address" id="field2" 
            disabled="disabled"  /&gt;&lt;/td&gt;&lt;td&gt;&lt;input id="myCheckBox2" type="checkbox" 
             onclick="enableText2(this.checked, 'field2');" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;input type=""submit value="submit"/&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/form&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>and following is the respective JAVASCRIPT written in the HEAD section:</p>
  
  <pre><code>  &lt;script type="text/javascript"&gt;
    function enableText1(checkBool, textID)
    {
      text1 = document.getElementById(textID);
      //Disable the text field
      text1.disabled = !checkBool;
      //Clear value in the text field
      if (!checkBool) { text1.value = ''; }
    }
    function enableText2(checkBool, textID)
    {
      text2 = document.getElementById(textID);
      //Disable the text field
      text2.disabled = !checkBool;
      //Clear value in the text field
      if (!checkBool) { text2.value = ''; }
     }
    &lt;/script&gt;
  </code></pre>
  
  <p>I want user to check the checkbox to enable the textbox to edit it. What can a user do with it?  He can check the checkbox to edit it and when he unchecks it once again textbox will be disabled. That means, what he edited in the checkbox is going to be locked. To prevent him from doing it; I'm setting the textbox to empty; once he unchecks the checkbox. It's working up to it.  My real problem starts from here. when the textbox is disabled and he submits the records to update, it throws an error while accepting the value using POST method ($name=$_POST['name']) in update.php:</p>
  
  <blockquote>
    <p>Notice: Undefined variable: address in C:\xampp\htdocs\xampp\Test\HRMS\try\chcking with checkboxes\update.php on line 4</p>
  </blockquote>
  
  <p>My main intention is to update the record into the temporary table. When a record is submitted using disabled textbox or empty textbox; in that case I would like to fetch its value from the old table and store it into the temporary table. I do not know how clear I am but accepting some support from enthusiastic master's in coding here. Thanks in advance.</p>
  
  <p>please check my actual code. I am including both the pages below :</p>
  
  <pre><code>    &lt;?php
      session_start();
      if(!$_SESSION['logged'])
      {
          header("Location: login.php");
          exit;
      }
      echo 'Welcome, '.$_SESSION['user'];
      //echo 'Welcome, '.$_SESSION['email'];
      //echo 'Welcome, '.$_SESSION['eid'];
  
      ?&gt;
  
  
      &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
      &lt;html&gt;
      &lt;head&gt;
  
      &lt;script type="text/javascript"&gt;
      function enableText1(checkBool, textID)
        {
          text1 = document.getElementById(textID);
          //Disable the text field
          text1.disabled = !checkBool;
          //Clear value in the text field
          if (!checkBool) { text1.value = ''; }
  
        }
  
      &lt;/script&gt;
  
      &lt;/head&gt;
  
      &lt;body&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  
  
      &lt;?php
      $user=$_SESSION['user'];
      $email=$_SESSION['email'];
      $eid=$_SESSION['eid'];
      echo "&lt;br&gt;";
      //echo $email;
      //echo $eid;
      //echo $user;
      $con = mysql_connect("localhost","mars","mars");
      if (! $con)
      die(mysql_error());
  
      mysql_select_db("marsweb",$con);
  
      mysql_query(" UPDATE login_info SET user_staus=1 WHERE username='$email'");
  
      $query="SELECT * FROM emp_info WHERE eid='$eid'";
  
      //echo "$query";
  
      $result=mysql_query($query);
      $num=mysql_num_rows($result);
  
      $i=0;
      while ($i &lt; $num) {
      $userid=mysql_result($result,$i,"eid"); 
      $name=mysql_result($result,$i,"ename");
      $password=mysql_result($result,$i,"password");
      $address=mysql_result($result,$i,"address");
      $source=mysql_result($result,$i,"source");
      $salary=mysql_result($result,$i,"salary");
      $zip=mysql_result($result,$i,"zip");
      $mobile=mysql_result($result,$i,"mobile");
      $email=mysql_result($result,$i,"email");
      ?&gt;
      &lt;div class="go_right"&gt;
      &lt;table width="100" cellpadding="10" cellspacing="0" border="2" align="center"&gt;
  
  
      &lt;form action="change_record1.php" method="post"&gt;
      &lt;tr&gt;
      &lt;td&gt;Employee ID&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="userid" value="&lt;?php echo "$userid" ?&gt;" readonly&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;Name:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="name" value="&lt;?php echo "$name"?&gt;"  readonly&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;!--&lt;tr&gt;
      &lt;td&gt;Password: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="password" value="&lt;?php echo "$password"?&gt;" &gt;&lt;/td&gt;
      &lt;/tr&gt;--&gt;
      &lt;tr&gt;
      &lt;td&gt;Address:&lt;/td&gt;&lt;td&gt; &lt;input type="text" name="address" value="&lt;?php echo "$address"?&gt;" id="field1"  dissabled="disabled"  /&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input id="myCheckBox1" type="checkbox" onClick="enableText1(this.checked, 'field1');" /&gt;&lt;/td&gt;&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;Source: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="source" value="&lt;?php echo "$source"?&gt;"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;Salary: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="salary" value="&lt;?php echo "$salary"?&gt;" readonly&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Mobile:&lt;/td&gt;&lt;td&gt; &lt;input type="text" name="mobile" value="&lt;?php echo "$mobile"?&gt;"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;Zip: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="zip" value="&lt;?php echo "$zip"?&gt;"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;Email: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="email" value="&lt;?php echo "$email"?&gt;" readonly&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr style="border:#FFF";&gt;
      &lt;td&gt;&lt;input type="Submit" value="Update"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/form&gt;
      &lt;/table&gt;
      &lt;?php
      ++$i;
      }
      ?&gt;
  </code></pre>
  
  <p>and the php page which will update the temporary table is given below...</p>
  
  <pre><code>    &lt;?php
      session_start();
      if(!$_SESSION['logged'])
      {
          header("Location: login.php");
          exit;
      }
      echo 'Welcome, '.$_SESSION['user'];
      echo "&lt;br&gt;";
      echo "&lt;br&gt;";
  
      ?&gt;
  
  
      &lt;?php
      $userid=$_POST['userid'];
      //$name=$_POST['name'];
      //$password=$_POST['password'];
      if(isset($_POST['address']))
      $address=$_POST['address'];
      $source=$_POST['source'];
      $salary=$_POST['salary'];
      $mobile=$_POST['mobile'];
      $zip=$_POST['zip'];
      $email=$_POST['email'];
  
      $con = mysql_connect("localhost","mars","mars");
      if (! $con)
      die(mysql_error());
  
      mysql_select_db("marsweb",$con);
  
      //echo $userid; echo "&lt;br&gt;";
      echo $address;  echo "&lt;br&gt;";
  
      if($address=="")
      {
          $query1="select address from `emp_info` where email='$email'";
          $fetched1=mysql_query($query1);
          while($record1=mysql_fetch_assoc($fetched1))
          {
              while(each($fetched1))
              { 
                  $address=$record1["address"];
              }
          }
      }
  
      echo $address;
  
      mysql_query("UPDATE temp_emp_info SET eid='$userid' , address='$address' , source='$source' , mobile='$mobile' , zip='$zip'  WHERE eid='$userid'");
  
      echo "&lt;br&gt;";echo "&lt;br&gt;";echo "&lt;br&gt;";
      echo "&lt;center&gt;&lt;h2&gt;Record updated&lt;/h2&gt;&lt;/center&gt;&lt;br&gt;&lt;br&gt;";
      ?&gt;
  </code></pre>