redirect brings up page with outdated information
<p>I have a character creation form where you enter the name of your character then press submit. It then brings up a success page. However, I don't want the user to be able to use their back button to return to the character creation page, so on the character creation page I redirect to the main menu page if it is detected that the referring page was the success page. However when it brings up the main menu page, the information it shows is out of date. You have to refresh the page for it to reflect the latest changes. It's almost as if the redirect is bringing up a cached version of the page....</p>

<p>Any ideas why the latest changes aren't being shown on redirect?</p>

<pre><code>&lt;?php 

// First we execute our common code to connection to the database and start the session 
define('MyConst', TRUE);

include('database.class.php');
include('table.class.php'); 
include('user.class.php');
include('loginattempts.class.php');
include('timer.class.php'); 
include('functions.php'); 
include('loginf.php');
include('character.class.php');
include('playercharacter.class.php');

$dbo = database::getInstance();
$dbo -&gt; connect("***********", "********", "*********", "********", array(PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES utf8')); 

secSessionStart();

// At the top of the page we check to see whether the user is logged in or not 
if(empty($_SESSION['user'])) 
{ 
    // If they are not, we redirect them to the login page. 
    header("Location: login.php"); 

    // Remember that this die statement is absolutely critical.  Without it, 
    // people can view your members-only content without logging in. 
    die("Redirecting to login.php"); 
} 

// Everything below this point in the file is secured by the login system 
if($_SERVER['HTTP_REFERER'] == "success.php") {
    // If they are not, we redirect them to the login page. 
    header("Location: mainmenu.php"); 

    // Remember that this die statement is absolutely critical.  Without it, 
    // people can view your members-only content without logging in. 
    die("Redirecting to mainmenu.php");
} 
if(!empty($_POST)) {

    $character = new character();
    $data = array("character_name" =&gt; $_POST['charactername'], "health" =&gt; 0, "money" =&gt; 1500, "exp" =&gt; 0, "rank" =&gt; 0, "points" =&gt; 0); 
    $character -&gt; bind($data);
    $character -&gt; store();
    $character_id = $dbo -&gt; getConnection() -&gt; lastInsertId();

    $playercharacter = new playercharacter();
    $data = array("character_id" =&gt; $character_id, "user_id" =&gt; $_SESSION['user']['user_id']);
    $playercharacter -&gt; bind($data);
    $playercharacter -&gt; store();

    $query = "SELECT * FROM playercharacter WHERE character_id = :character_id"; 

    try { 
        $stmt = $dbo-&gt;getConnection()-&gt;prepare($query); 
        $result = $stmt-&gt;execute(array(':character_id'=&gt;$row['character_id'])); 
    } 
    catch(PDOException $ex) { 
        die("Failed to run query4: " . $ex-&gt;getMessage()); 
    }

    $row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
    $_SESSION['playercharacter'] = $row;

    // If they are not, we redirect them to the login page. 
    header("Location: success.php"); 

    // Remember that this die statement is absolutely critical.  Without it, 
    // people can view your members-only content without logging in. 
    die("Redirecting to success.php");    
 }         
?&gt;

&lt;!DOCTYPE HTML&gt;
&lt;head&gt;
&lt;meta http-equiv="content-type" content="text/html" /&gt;
&lt;meta name="author" content="lolkittens" /&gt;

&lt;title&gt;Untitled 5&lt;/title&gt;
&lt;/head&gt;

 &lt;body&gt; 
&lt;h1&gt;Create Character&lt;/h1&gt; 
&lt;form action="createcharacter.php" method="post"&gt; 
    Enter name:&lt;br /&gt; 
    &lt;input type="text" name="charactername" value="" /&gt; 
    &lt;br /&gt;&lt;br /&gt; 
    &lt;input type="submit" value="Create" /&gt; 
&lt;/form&gt; 
&lt;/body&gt;
</code></pre>

<p></p>

<p>createcharacter.php</p>

<pre><code>&lt;?php 

// First we execute our common code to connection to the database and start the session 
define('MyConst', TRUE);

include('database.class.php');
include('table.class.php'); 
include('user.class.php');
include('loginattempts.class.php');
include('timer.class.php'); 
include('functions.php'); 
include('loginf.php');

$dbo = database::getInstance();
$dbo -&gt; connect("*************", "*********", "**********", "***********", array(PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES utf8')); 

secSessionStart();

// At the top of the page we check to see whether the user is logged in or not 
if(empty($_SESSION['user'])) 
{ 
    // If they are not, we redirect them to the login page. 
    header("Location: login.php"); 

    // Remember that this die statement is absolutely critical.  Without it, 
    // people can view your members-only content without logging in. 
    die("Redirecting to login.php"); 
} 

// Everything below this point in the file is secured by the login system 

// We can display the user's username to them by reading it from the session array.  Remember that because 
// a username is user submitted content we must use htmlentities on it before displaying it to the user. 

 ?&gt;
 &lt;!DOCTYPE html&gt;
 &lt;html&gt;
 &lt;head&gt;
  &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;
  &lt;/script&gt;  
 &lt;/head&gt;
 &lt;body&gt;
 &lt;a href="mainmenu.php"&gt;Success!&lt;/a&gt;&lt;/a&gt;

  &lt;/body&gt;
  &lt;/html&gt;
</code></pre>

<p>success.php</p>

<pre><code>&lt;?php 

// First we execute our common code to connection to the database and start the session 
define('MyConst', TRUE);

include('database.class.php');
include('table.class.php'); 
include('user.class.php');
include('loginattempts.class.php');
include('timer.class.php'); 
include('functions.php'); 
include('loginf.php');

$dbo = database::getInstance();
$dbo -&gt; connect("*********************", "******************",     
    "***************", "*****************", array(PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES utf8')); 

secSessionStart();

    // At the top of the page we check to see whether the user is logged in or not 
    if(empty($_SESSION['user'])) 
    { 
      // If they are not, we redirect them to the login page. 
    header("Location: login.php"); 

    // Remember that this die statement is absolutely critical.  Without it, 
    // people can view your members-only content without logging in. 
    die("Redirecting to login.php"); 
} 

// Everything below this point in the file is secured by the login system 

// We can display the user's username to them by reading it from the session array.  Remember that because 
// a username is user submitted content we must use htmlentities on it before displaying it to the user. 
 ?&gt;

&lt;?php 
$stmt = $dbo-&gt;getConnection()-&gt;prepare("SELECT count(character_name) FROM      
playercharacter JOIN `character` ON (playercharacter.character_id =    
`character`.character_id) WHERE user_id = :user_id");
$query_params = array(':user_id'=&gt;$_SESSION['user'][user_id]);       
// Execute the prepared query.
$result = $stmt-&gt;execute($query_params);
$rows = $stmt-&gt;fetch(PDO::FETCH_NUM);
echo $rows[0];
$createCharacters = 4 - $rows[0];

for($i = 0; $i &lt; $createCharacters; $i++) {
    echo '&lt;a href="createcharacter.php"&gt;Create Character&lt;/a&gt;&lt;br /&gt;';
}
for($i = 0; $i &lt; $rows[0]; $i++) {
    echo '&lt;a href="loadplayer.php?id='.$rows[0].'"&gt;Play&lt;/a&gt; &lt;br /&gt;';
// echo '&lt;a href="loadplayer.php"&gt;Create Character&lt;/a&gt;&lt;br /&gt;`;
}            
?&gt;

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;script src="functions.js"&gt;&lt;/script&gt;  
&lt;/head&gt;
&lt;body&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>mainmenu.php</p>
