title: Database Query Takes One Reload After Form Submit To Update
body: <p>I want once a user updates the information on their profiles not to reload  the input boxes instantly. </p>
  
  <p>Here is a example:</p>
  
  <pre><code>User updates his age box:
  User inputs 10
  Displays 10
  User inputs 20
  Displays 10
  Page Reload
  Displays 20
  </code></pre>
  
  <p>I do not know why this is happening. It takes a FULL page reload and page refresh for the correct information to be displayed :( </p>
  
  <p>Yet once the information is updated in the database, and I print the information - it is correct. That does not work though sense the button reloads the whole page. Here are the variables getting set:</p>
  
  <hr>
  
  <h2>Variables</h2>
  
  <pre><code>function utf8_encode_string($value) {
      if (empty($_POST[$value])) {
          $str = "";
          return $str;
      }
      else {
          $str = utf8_encode(htmlspecialchars(trim($_POST[$value]), ENT_QUOTES));
          return $str;
      }
  }
  
  $urlquery = new user("username", $accounturl, $connection); 
  $locationinput = utf8_encode_string($urlquery-&gt;user_information("location"));
  if (!$locationinput) {
      $locationinput = utf8_encode(htmlspecialchars(trim($urlquery-&gt;user_information("location")), ENT_QUOTES));
  }
  </code></pre>
  
  <hr>
  
  <h2>Form</h2>
  
  <pre><code>&lt;form method="post"&gt;
      &lt;input 
          type="text" 
          name="location" 
          id="locationinput" 
          value="&lt;?php print utf8_decode($locationinput); ?&gt;" 
       /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <hr>
  
  <h2>Class</h2>
  
  <pre><code>class user {
  
      public function __construct($row_name_1, $row_value_1, $connection) {
          $this-&gt;row_name_1 = $row_name_1;
          $this-&gt;row_value_1 = $row_value_1;
          $this-&gt;connection = $connection;
      }   
  
      public function user_update_information($updatecolumn, $updatecolumn_value) {
          $query = "UPDATE users SET $updatecolumn = :updatecolumn WHERE $this-&gt;row_name_1 = :row_value_1";
          $stmt = $this-&gt;connection-&gt;prepare($query);
          $stmt-&gt;execute(array(':updatecolumn' =&gt; $updatecolumn_value,
                               ':row_value_1' =&gt; $this-&gt;row_value_1));
      }
  
      public function user_information($information) {
          $query = "SELECT * FROM users WHERE $this-&gt;row_name_1 = :row_value_1";
          $params = array(':row_value_1' =&gt; $this-&gt;row_value_1);
          try{
              $stmt = $this-&gt;connection-&gt;prepare($query);
              $result = $stmt-&gt;execute($params);
          }
          catch(PDOException $ex){
              echo ("Failed to run query: " . $ex-&gt;getMessage());
          }
          $columns = $stmt-&gt;fetch();
          return $columns[$information];
      }
  }
  </code></pre>
  
  <hr>
  
  <h2>Database Update</h2>
  
  <pre><code>$location_for_database = "";
  if (isset($locationinput)) 
  {
      $location_for_database = $locationinput;
  }
  else 
  {
      $location_for_database = "";
  }
  
  $updateinfo = new user("id", $_SESSION["logged_in"], $connection);
  $updateinfo-&gt;user_update_information(
      "location", 
      ($location_for_database)
  );
  </code></pre>
  
  <hr>
  
  <p>If you would like my full code you can find it here: <a href="http://pastebin.com/Cg2LQd7T" rel="nofollow">http://pastebin.com/Cg2LQd7T</a> </p>
  
  <p>Please, let me know if you would like me to explain my issue better. I have been working on this for over a month now, and I can not fix it! :(</p>