title: display a success message after form submission in smarty php template?
body: <p>I am trying to display a success message after form submission in smarty php template.</p>
  
  <p>once a user registers on the site and their data has been entered into the mysql database, I need to display a success message on the same page.</p>
  
  <p>I have the following in my php page:</p>
  
  <pre><code>    session_start();
      ob_start();
      $success = "";
  
      $stmt = mysqli_prepare(
          $db_conx,
          "INSERT INTO (XXX, XXX, XXX) VALUES (?, ?, ?)");
  
      ;
      //after validation, of course
      mysqli_stmt_bind_param($stmt, "sss", $firstname, $lastname, $username);
      mysqli_stmt_execute($stmt);
      if (mysqli_affected_rows($db_conx))
      {
          mysqli_stmt_close($stmt);//&lt;-- CLEAN UP AFTER YOURSELF!
          //update was successful
          $id = mysqli_insert_id($db_conx);
      }
      printf("&lt;script&gt;location.href='register.PHP'&lt;/script&gt;");
  
      $success = "You have successfully registered your account.";
      exit();
          } 
        } 
      } 
  $smarty-&gt;assign("success",$success);
  </code></pre>
  
  <p>And I have this in my template page right above the <code>&lt;form&gt;</code> tag:</p>
  
  <pre><code>{$success}
  </code></pre>
  
  <p>however, I get the data entered into mysql and I get redirected to the register.php page but I don't get the success message!</p>
  
  <p>could someone please help me out with this?</p>
  
  <p>Thanks in advance.</p>