title: All is working except if($_POST['submit']=='Update')
body: <p>I have a working registration and login system. I am trying to create a form where a user can add product registration info (via mysql update). I can't seem to get the db to actually update the fields. What am I missing here?!? </p>
  
  <pre><code>&lt;?php 
  
  define('INCLUDE_CHECK',true);
  
  require 'connect.php';
  require 'functions.php';
  // Those two files can be included only if INCLUDE_CHECK is defined
  
  
  session_name('tzLogin');
  // Starting the session
  
  session_set_cookie_params(2*7*24*60*60);
  // Making the cookie live for 2 weeks
  
  session_start();
  
  if($_SESSION['id'] &amp;&amp; !isset($_COOKIE['tzRemember']) &amp;&amp; !$_SESSION['rememberMe'])
  {
      // If you are logged in, but you don't have the tzRemember cookie (browser restart)
      // and you have not checked the rememberMe checkbox:
  
      $_SESSION = array();
      session_destroy();
  
      // Destroy the session
  }
  
  
  if(isset($_GET['logoff']))
  {
      $_SESSION = array();
      session_destroy();
  
      header("Location: index_login3.php");
      exit;
  }
  
  if($_POST['submit']=='Login')
  {
      // Checking whether the Login form has been submitted
  
      $err = array();
      // Will hold our errors
  
  
      if(!$_POST['username'] || !$_POST['password'])
          $err[] = 'All the fields must be filled in!';
  
      if(!count($err))
      {
          $_POST['username'] = mysql_real_escape_string($_POST['username']);
          $_POST['password'] = mysql_real_escape_string($_POST['password']);
          $_POST['rememberMe'] = (int)$_POST['rememberMe'];
  
          // Escaping all input data
  
          $row = mysql_fetch_assoc(mysql_query("SELECT * FROM electrix_users WHERE usr='{$_POST['username']}' AND pass='".md5($_POST['password'])."'"));
  
          if($row['usr'])
          {
              // If everything is OK login
  
              $_SESSION['usr']=$row['usr'];
              $_SESSION['id'] = $row['id'];
              $_SESSION['email'] = $row['email'];
              $_SESSION['first'] = $row['first'];
              $_SESSION['last'] = $row['last'];
              $_SESSION['address1'] = $row['address1'];
              $_SESSION['address2'] = $row['address2'];
              $_SESSION['city'] = $row['city'];
              $_SESSION['state'] = $row['state'];
              $_SESSION['zip'] = $row['zip'];
              $_SESSION['country'] = $row['country'];
              $_SESSION['product1'] = $row['product1'];
              $_SESSION['serial1'] = $row['serial1'];
              $_SESSION['product2'] = $row['product2'];
              $_SESSION['serial2'] = $row['serial2'];
              $_SESSION['product3'] = $row['product3'];
              $_SESSION['serial3'] = $row['serial3'];
              $_SESSION['rememberMe'] = $_POST['rememberMe'];
  
              // Store some data in the session
  
              setcookie('tzRemember',$_POST['rememberMe']);
  
          }
  
  
          else $err[]='Wrong username and/or password!';
      }
  
      if($err)
      $_SESSION['msg']['login-err'] = implode('&lt;br /&gt;',$err);
      // Save the error messages in the session
  
      header("Location: index_login3.php");
      exit;
  
  }
  else if($_POST['submit']=='Register')
  {
      // If the Register form has been submitted
  
      $err = array();
  
      if(strlen($_POST['username'])&lt;4 || strlen($_POST['username'])&gt;32)
      {
          $err[]='Your username must be between 3 and 32 characters!';
      }
  
      if(preg_match('/[^a-z0-9\-\_\.]+/i',$_POST['username']))
      {
          $err[]='Your username contains invalid characters!';
      }
  
      if(!checkEmail($_POST['email']))
      {
          $err[]='Your email is not valid!';
      }
  
      if(!count($err))
      {
          // If there are no errors
  
          $pass = substr(md5($_SERVER['REMOTE_ADDR'].microtime().rand(1,100000)),0,6);
          // Generate a random password
  
          $_POST['email'] = mysql_real_escape_string($_POST['email']);
          $_POST['username'] = mysql_real_escape_string($_POST['username']);
          $_POST['first'] = mysql_real_escape_string($_POST['first']);
          $_POST['last'] = mysql_real_escape_string($_POST['last']);
          $_POST['address1'] = mysql_real_escape_string($_POST['address1']);
          $_POST['address2'] = mysql_real_escape_string($_POST['address2']);
          $_POST['city'] = mysql_real_escape_string($_POST['city']);
          $_POST['state'] = mysql_real_escape_string($_POST['state']);
          $_POST['zip'] = mysql_real_escape_string($_POST['zip']);
          $_POST['country'] = mysql_real_escape_string($_POST['country']);
          // Escape the input data
  
  
          mysql_query("   INSERT INTO electrix_users(usr,pass,email,first,last,address1,address2,city,state,zip,country,regIP,dt) 
                          VALUES(
  
                              '".$_POST['username']."',
                              '".md5($pass)."',
                              '".$_POST['email']."',
                              '".$_POST['first']."',
                              '".$_POST['last']."',
                              '".$_POST['address1']."',
                              '".$_POST['address2']."',
                              '".$_POST['city']."',
                              '".$_POST['state']."',
                              '".$_POST['zip']."',
                              '".$_POST['country']."',
                              '".$_SERVER['REMOTE_ADDR']."',
                              NOW()
  
                          )");
  
          if(mysql_affected_rows($link)==1)
          {
              send_mail(  'noreply@electrixpro.com',
                          $_POST['email'],
                          'Your New Electrix User Password',
                          'Thank you for registering at www.electrixpro.com. Your password is: '.$pass);
  
              $_SESSION['msg']['reg-success']='We sent you an email with your new password!';
          }
          else $err[]='This username is already taken!';
      }
  
      if(count($err))
      {
          $_SESSION['msg']['reg-err'] = implode('&lt;br /&gt;',$err);
      }   
  
      header("Location: index_login3.php");
      exit;
  }
  
  if($_POST['submit']=='Update')
  
  {   
  
      {
        mysql_query(" UPDATE electrix_users(product1,serial1,product2,serial2,product3,serial3) WHERE usr='{$_POST['username']}' 
                VALUES(
  
                '".$_POST['product1']."',
                '".$_POST['serial1']."',
                '".$_POST['product2']."',
                '".$_POST['serial2']."',
                '".$_POST['product3']."',
                '".$_POST['serial3']."',                          
  
            )");          
  
          if(mysql_affected_rows($link)==1)
          {
              $_SESSION['msg']['upd-success']='Thank you for registering your Electrix product';
          }
          else $err[]='So Sad!';
      }
  
      if(count($err))
      {
          $_SESSION['msg']['upd-err'] = implode('&lt;br /&gt;',$err);
      }   
  
      header("Location: index_login3.php");
      exit;
  
  }
  
  if($_SESSION['msg'])
  {
      // The script below shows the sliding panel on page load
  
      $script = '
      &lt;script type="text/javascript"&gt;
  
          $(function(){
  
              $("div#panel").show();
              $("#toggle a").toggle();
          });
  
      &lt;/script&gt;';
  
  }
  ?&gt;
  </code></pre>
  
  <p>Here are the forms:</p>
  
  <pre><code>   &lt;!-- Panel --&gt;
  &lt;div id="toppanel"&gt;
      &lt;div id="panel"&gt;
          &lt;div class="content clearfix"&gt;
              &lt;div class="left"&gt;
                  &lt;h1&gt;My Electrix Account &lt;/h1&gt;
                  &lt;p class="grey"&gt;View and edit your contact information and product registrations&lt;/p&gt;
              &lt;/div&gt;
  
  
              &lt;?php
  
              if(!$_SESSION['id']):
  
              ?&gt;
  
              &lt;div class="left"&gt;
                  &lt;!-- Login Form --&gt;
                  &lt;form class="clearfix" action="" method="post"&gt;
                      &lt;h1&gt;Member Login&lt;/h1&gt;
  
                      &lt;?php
  
                          if($_SESSION['msg']['login-err'])
                          {
                              echo '&lt;div class="err"&gt;'.$_SESSION['msg']['login-err'].'&lt;/div&gt;';
                              unset($_SESSION['msg']['login-err']);
                          }
                      ?&gt;
  
                      &lt;label class="grey" for="username"&gt;Username:&lt;/label&gt;
                      &lt;input class="field" type="text" name="username" id="username" value="" size="23" /&gt;
                      &lt;label class="grey" for="password"&gt;Password:&lt;/label&gt;
                      &lt;input class="field" type="password" name="password" id="password" size="23" /&gt;
                      &lt;label&gt;&lt;input name="rememberMe" id="rememberMe" type="checkbox" checked="checked" value="1" /&gt; &amp;nbsp;Remember me&lt;/label&gt;
                      &lt;div class="clear"&gt;&lt;/div&gt;
                      &lt;input type="submit" name="submit" value="Login" class="bt_login" /&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
              &lt;div class="left right"&gt;            
                  &lt;!-- Register Form --&gt;
                  &lt;form action="" method="post"&gt;
                      &lt;h1&gt;Not a member yet? Sign Up!&lt;/h1&gt;     
  
                      &lt;?php
  
                          if($_SESSION['msg']['reg-err'])
                          {
                              echo '&lt;div class="err"&gt;'.$_SESSION['msg']['reg-err'].'&lt;/div&gt;';
                              unset($_SESSION['msg']['reg-err']);
                          }
  
                          if($_SESSION['msg']['reg-success'])
                          {
                              echo '&lt;div class="success"&gt;'.$_SESSION['msg']['reg-success'].'&lt;/div&gt;';
                              unset($_SESSION['msg']['reg-success']);
                          }
                      ?&gt;
  
                      &lt;label class="grey" for="username"&gt;Username*:&lt;/label&gt;
                      &lt;input class="field" type="text" name="username" id="username" value="" size="23" /&gt;
                      &lt;label class="grey" for="email"&gt;Email*:&lt;/label&gt;
                      &lt;input class="field" type="text" name="email" id="email" size="23" /&gt;
                      &lt;label class="grey" for="first"&gt;First Name:&lt;/label&gt;
                      &lt;input class="field" type="text" name="first" id="first" size="23" /&gt;
                      &lt;label class="grey" for="last"&gt;Last Name:&lt;/label&gt;
                      &lt;input class="field" type="text" name="last" id="last" size="23" /&gt;
                      &lt;label class="grey" for="address1"&gt;Address line 1:&lt;/label&gt;
                      &lt;input class="field" type="text" name="address1" id="address1" size="23" /&gt;
                      &lt;label class="grey" for="address2"&gt;Address line 2:&lt;/label&gt;
                      &lt;input class="field" type="text" name="address2" id="address2" size="23" /&gt;
                      &lt;label class="grey" for="city"&gt;City:&lt;/label&gt;
                      &lt;input class="field" type="text" name="city" id="city" size="23" /&gt;
                      &lt;label class="grey" for="state"&gt;State/Province:&lt;/label&gt;
                      &lt;input class="field" type="text" name="state" id="state" size="23" /&gt;
                      &lt;label class="grey" for="zip"&gt;Zip/Postal Code:&lt;/label&gt;
                      &lt;input class="field" type="text" name="zip" id="zip" size="23" /&gt;
                      &lt;label class="grey" for="country"&gt;Country:&lt;/label&gt;
                      &lt;input class="field" type="text" name="country" id="country" size="23" /&gt;
                      &lt;p&gt;
                      &lt;label&gt;A password will be e-mailed to you.&lt;/label&gt;
                      &lt;input type="submit" name="submit" value="Register" class="bt_register" /&gt;
                      &lt;/p&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
  
              &lt;?php
  
              else:
  
              ?&gt;
  
  
              &lt;div class="left"&gt;
  
              &lt;h1&gt;User Information&lt;/h1&gt;            
  
              &lt;p&gt;
              &lt;?php echo $_SESSION['first']; ?&gt;
              &lt;?php echo $_SESSION['last']; ?&gt;&lt;br /&gt;
              &lt;?php echo $_SESSION['address1']; ?&gt;
              &lt;?php echo $_SESSION['address2']; ?&gt;&lt;br /&gt;
              &lt;?php echo $_SESSION['city']; ?&gt;,
              &lt;?php echo $_SESSION['state']; ?&gt;
              &lt;?php echo $_SESSION['zip']; ?&gt;&lt;br /&gt;
              &lt;?php echo $_SESSION['country']; ?&gt;
              &lt;/p&gt;
              &lt;p&gt;Email: &lt;?php echo $_SESSION['email']; ?&gt;&lt;/p&gt;
              &lt;p&gt;&lt;a href="downloads.php"&gt;Downloads&lt;/a&gt;&lt;/p&gt;
              &lt;a href="?logoff"&gt;Log off&lt;/a&gt;
  
              &lt;/div&gt;
  
              &lt;div class="left right"&gt;
  
                  &lt;!-- Product Registration Form --&gt;
  
                  &lt;form class="clearfix" action="" method="post"&gt;
                      &lt;h1&gt;Product Registration&lt;/h1&gt;
  
                      &lt;?php
  
                          if($_SESSION['msg']['upd-err'])
                          {
                              echo '&lt;div class="err"&gt;'.$_SESSION['msg']['upd-err'].'&lt;/div&gt;';
                              unset($_SESSION['msg']['upd-err']);
                          }
  
                          if($_SESSION['msg']['upd-success'])
                          {
                              echo '&lt;div class="success"&gt;'.$_SESSION['msg']['upd-success'].'&lt;/div&gt;';
                              unset($_SESSION['msg']['upd-success']);
                          }
                      ?&gt;
  
                      &lt;label class="grey" for="product1"&gt;Product 1:&lt;/label&gt;
                      &lt;input class="field" type="text" name="product1" id="product1" value="&lt;?php echo $_SESSION['product1']; ?&gt;" size="23" /&gt;
                      &lt;label class="grey" for="serial1"&gt;Serial 1:&lt;/label&gt;
                      &lt;input class="field" type="text" name="serial1" id="serial1" value="&lt;?php echo $_SESSION['serial1']; ?&gt;" size="23" /&gt;
                      &lt;label class="grey" for="product2"&gt;Product 2:&lt;/label&gt;
                      &lt;input class="field" type="text" name="product2" id="product2" value="&lt;?php echo $_SESSION['product2']; ?&gt;" size="23" /&gt;
                      &lt;label class="grey" for="serial2"&gt;Serial 2:&lt;/label&gt;
                      &lt;input class="field" type="text" name="serial2" id="serial2" value="&lt;?php echo $_SESSION['serial2']; ?&gt;" size="23" /&gt;
                      &lt;label class="grey" for="product3"&gt;Product 3:&lt;/label&gt;
                      &lt;input class="field" type="text" name="product3" id="product3" value="&lt;?php echo $_SESSION['product3']; ?&gt;" size="23" /&gt;
                      &lt;label class="grey" for="serial3"&gt;Serial 3:&lt;/label&gt;
                      &lt;input class="field" type="text" name="serial3" id="serial3" value="&lt;?php echo $_SESSION['serial3']; ?&gt;" size="23" /&gt;
                      &lt;div class="clear"&gt;&lt;/div&gt;
                      &lt;input type="submit" name="submit" value="Update" class="bt_login" /&gt;
                  &lt;/form&gt;
  
              &lt;/div&gt;
  
              &lt;?php
              endif;
              ?&gt;
          &lt;/div&gt;
      &lt;/div&gt; &lt;!-- /login --&gt;  
  
  
  
      &lt;!-- The tab on top --&gt; 
      &lt;div class="tab"&gt;
          &lt;ul class="login"&gt;
              &lt;li class="left"&gt;&amp;nbsp;&lt;/li&gt;
              &lt;li&gt;Hello &lt;?php echo $_SESSION['usr'] ? $_SESSION['usr'] : 'Guest';?&gt;!&lt;/li&gt;
              &lt;li class="sep"&gt;|&lt;/li&gt;
              &lt;li id="toggle"&gt;
                  &lt;a id="open" class="open" href="#"&gt;&lt;?php echo $_SESSION['id']?'Open Panel':'Log In | Register';?&gt;&lt;/a&gt;
                  &lt;a id="close" style="display: none;" class="close" href="#"&gt;Close Panel&lt;/a&gt;         
              &lt;/li&gt;
              &lt;li class="right"&gt;&amp;nbsp;&lt;/li&gt;
          &lt;/ul&gt; 
      &lt;/div&gt; &lt;!-- / top --&gt;
  
  &lt;/div&gt; &lt;!--panel --&gt;
  </code></pre>