title: Refreshing page after sql update
body: <p>After submitting information to my database, I want to refresh the page to show those changes, as when the form has been processed.  The page "reloads" after submission but does not reflect the changes, so I assumed I would need to add a refresh command in when submit is pressed, but it seems to be too quick?</p>
  
  <p>So I added a refresh time, but even cranking it up to 50 I got the same result.</p>
  
  <p>If I press the button twice it refreshes with the correct information.  Is there a better way to do this?</p>
  
  <pre><code>&lt;?php
  ini_set('display_errors',1);
  error_reporting(E_ALL);
  
  include_once '../includes/conn.php';
  
  if(!$user-&gt;is_loggedin()){
      $user-&gt;redirect('../users/login.php');
  }
  
  $id = $_SESSION['session'];
  $stmt = $conn-&gt;prepare("SELECT * FROM users WHERE id=:id");
  $stmt-&gt;execute(array(":id"=&gt;$id));
  
  $userRow=$stmt-&gt;fetch(PDO::FETCH_ASSOC);
  $location = isset($_POST['location']) ? $_POST['location'] : '';
  $about = isset($_POST['about']) ? $_POST['about'] : '';
  $title = isset($_POST['title']) ? $_POST['title'] : '';
  
  if($title!=''){
      $sql = "UPDATE users SET title=:title WHERE id=:id";    
      $stmt = $conn-&gt;prepare($sql); 
      if($stmt == false){ 
          $error = "User Title update failed. Please try again.";
      } 
  
      $result = $stmt-&gt;execute(array(":title"=&gt;$title, ":id"=&gt;$id));
  
      if($result == false) { 
          $error = "User Title update failed. Please try again.";
      } 
      $count = $stmt-&gt;rowCount();
  } 
  
  if($location!=''){
      $sql = "UPDATE users SET location=:location WHERE id=:id";  
      $stmt = $conn-&gt;prepare($sql); 
      if($stmt == false){ 
          $error = "User Location update failed. Please try again.";
      } 
  
      $result = $stmt-&gt;execute(array(":location"=&gt;$location, ":id"=&gt;$id));
  
      if($result == false) { 
          $error = "User location update failed. Please try again.";
      } 
      $count = $stmt-&gt;rowCount();
  } 
  
  if($about!=''){
      $sql = "UPDATE users SET about=:about WHERE id=:id";    
      $stmt = $conn-&gt;prepare($sql); 
      if($stmt == false){ 
          $error = "about Me update failed. Please try again.";
      } 
  
      $result = $stmt-&gt;execute(array(":about"=&gt;$about, ":id"=&gt;$id));
  
      if($result == false) { 
          $error = "about Me location update failed. Please try again.";
      } 
      $count = $stmt-&gt;rowCount();
  } 
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;    
  &lt;head&gt;
      &lt;title&gt;EpicOwl UK | CMS Users Edit Profile&lt;/title&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="../css/main.css"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="header"&gt;
      &lt;a href="index.php"&gt;&lt;img id="logo" src="../images/logo.png" /&gt;&lt;/a&gt;
      &lt;div id="navigation"&gt;
          &lt;ul&gt;
              &lt;a href="../index.php"&gt;&lt;li&gt;Home&lt;/li&gt;&lt;/a&gt;
              &lt;a href="./profile.php"&gt;&lt;li&gt;My Profile&lt;/li&gt;&lt;/a&gt;
              &lt;a href="../admin/index.php"&gt;&lt;li&gt;Admin Panel&lt;/li&gt;&lt;/a&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="content"&gt;
  &lt;form method="post"&gt;&lt;br /&gt;
      &lt;h2&gt;Edit Profile&lt;/h2&gt;
      &lt;label&gt;&lt;strong&gt;User Title:&lt;/strong&gt;&lt;/label&gt;&lt;br /&gt;
      &lt;input type="text" name="title" maxlength="50" placeholder="&lt;?php echo ($userRow['title']); ?&gt;" /&gt;&lt;br /&gt;&lt;br /&gt;
      &lt;label&gt;&lt;strong&gt;My Location:&lt;/strong&gt;&lt;/label&gt;&lt;br /&gt;
      &lt;input type="text" name="location" maxlength="50" placeholder="&lt;?php echo ($userRow['location']); ?&gt;" /&gt;&lt;br /&gt;&lt;br /&gt;
      &lt;label&gt;&lt;strong&gt;About Me:&lt;/strong&gt;&lt;label&gt;&lt;br /&gt;
      &lt;textarea name="about" rows="13" cols="60" maxlength="255" placeholder="&lt;?php echo ($userRow['about']); ?&gt;"&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;
      &lt;button type="submit" name="update"&gt;Update&lt;/button&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
      &lt;?php
      if(isset($_POST['submit'])){
          header('refresh:20; Location: '.$_SERVER['REQUEST_URI']);
      }
      ?&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;div id="footer"&gt;
      &lt;p class="copyright"&gt;&amp;copy; EpicOwl UK. All Rights Reserved.&lt;/p&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>