title: Adding updated data using a form to MySQLi
body: <p>I am new to PHP and appreciate all the help I receive.</p>
  
  <p>OK so I now understand that simply resubmitting a form does not over write any previous data on the database what was ending before resubmitting the for.</p>
  
  <p>I was wondering how I would set it so that the database updates the data that needs updating with the new data.</p>
  
  <p>My form works 100% fine other then a few things I would like to iron out and this is one of them. I have looked around google and everything but I can't make sense of anything that I find as all answers are different and there is not a set answer to my question.</p>
  
  <pre><code>if(isset($_POST["signupbtn"])) {
      if ($log_username) {
          /// getting data from submitted form into local variables
          $x = preg_replace('#[^a-z 0-9]#i', '', $_POST['xbox']);
          $p  = preg_replace('#[^a-z 0-9]#i', '', $_POST['psn']);
          $s = preg_replace('#[^a-z 0-9]#i', '', $_POST['steam']);
          $ip = preg_replace('#[^0-9.]#', '', getenv('REMOTE_ADDR'));
          // DUPLICATE DATA CHECKS FOR GAMER PROFILES
          $sqli = "SELECT username FROM player WHERE xbox='$x' LIMIT 1";
          $query = mysqli_query($db_conx, $sqli); 
          $x_check = mysqli_num_rows($query);
          // -------------------------------------------
          if ($x_check &gt; 0){ 
              echo "Xbox Gamer-Tag already linked to a user on this website";
              exit();
          } else if (is_numeric($x[0])) {
              echo 'Xbox Gamer-Tag cannot begin with a number';
              exit();
          }
          $sqli = "SELECT username FROM player WHERE psn='$p' LIMIT 1";
          $query = mysqli_query($db_conx, $sqli); 
          $p_check = mysqli_num_rows($query);
          // -------------------------------------------
           if ($p_check &gt; 0){ 
              echo "PSN User already linked to a user on this website";
              exit();
          } else if (is_numeric($p[0])) {
              echo 'PSN User cannot begin with a number';
              exit();
          }
          $sqli = "SELECT username FROM player WHERE steam='$s' LIMIT 1";
          $query = mysqli_query($db_conx, $sqli); 
          $s_check = mysqli_num_rows($query);
          // FORM DATA ERROR HANDLING
           if ($s_check &gt; 0){ 
              echo "Steam account already linked to a user on this website";
              exit();
          } else if (is_numeric($s[0])) {
              echo 'Steam account cannot begin with a number';
              exit();
          } else  { $sqli = "INSERT INTO player (id, username, xbox, psn, steam, ip, created, lastupdated, notecheck)        
                  VALUES ('$id','$log_username','$x','$p','$s','$ip',NOW(),NOW(),NOW())"; 
                  $query = mysqli_query($db_conx, $sqli);
                     echo "Gamer Profiles Updated";
                  }   
  
          exit();
  
              if (!file_exists("p_player/$log_username")) {
                  mkdir("p_player/$log_username", 0755);
              } 
  
  
       }
  
  
  }
  </code></pre>
  
  <p>As you can see that is my current php what is working fine except the fact that I can't update information that has been submitted.</p>
  
  <p>Thank you for reading this and I hope someone is able to provide me with the knowledge that is need to preform this task.</p>
  
  <p>Thanks once again for your time it has taken for you to read this post.</p>